Maven plugin: Maven 4 warns about Plexus `@Component` injection
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:
MavenSessionis not a component; take it as@Parameter(defaultValue = "${session}", readonly = true).- Inject the other three with JSR-330 (
@Injecton 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diffplug/spotless
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
diffplug/spotless#3125 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
All issues in diffplug/spotless
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
aoqia194/leaf-loader#19 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/streampark#4521 ·
-
Update license yearOpen0 - Backlog 1 - Ready documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
cbor
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
FasterXML/jackson-dataformats-binary#844 ·
Maintainers usually reply within 1 day
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenAPITools/openapi-generator#25107 ·
Maintainers usually reply within 1 day