Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Maven plugin: Maven 4 warns about Plexus `@Component` injection

Open
#3,121 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
build-system

Research direction

Start in plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java and inspect the four @Component fields: RepositorySystem, ResourceManager, BuildContext and MavenSession. Apply the issue’s MavenSession parameter and JSR-330 injection guidance, then run the plugin under Maven 4 and Maven 3. Done means the Maven 4 validation warning is gone while Maven 3 support remains.

Written by the indexing model from the issue text.

Description

Running spotless-maven-plugin 3.10.3 under Maven 4.0.0-rc-7 prints a plugin validation warning on every build:

[WARNING]  * com.diffplug.spotless:spotless-maven-plugin:3.10.3
[WARNING]      - Plugin uses Plexus Component requirements (@Component annotation). Use Maven 4 Dependency Injection (for v4 plugins) or JSR 330 annotations (for v3 plugins) to inject dependencies instead.

The source is the four @Component fields in plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java: RepositorySystem, ResourceManager, BuildContext and MavenSession.

A fix that keeps Maven 3 support:

  • MavenSession is not a component; take it as @Parameter(defaultValue = "${session}", readonly = true).
  • Inject the other three with JSR-330 (@Inject on a constructor or on the fields).
Dominant language
Java
Stars
5.7k
Forks
563
Avg merge
1d 7h
Merged PRs (30d)
51

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.