gnodet opened a new pull request, #13880:
URL: https://github.com/apache/maven/pull/13880
## Description
Remove the `@Named` annotation from all SPI interfaces in `maven-api-spi`.
### Why `@Named` on SPI interfaces has no effect
1. **`DiIndexProcessor` does not run on `maven-api-spi`** — the annotation
processor that generates `META-INF/maven/org.apache.maven.api.di.Inject`
is not configured on this module, so no DI index is produced from it.
2. **Java does not inherit interface annotations to implementing classes** —
`getDeclaredAnnotations()` (used by `ReflectionUtils.qualifierOf()`) does
not traverse implemented interfaces. `@Named` is not `@Inherited`, so
placing it on an interface has no effect on implementing classes.
3. **The annotation is therefore purely decorative and misleading** — it
creates
the false impression that `@Named` on the interface is sufficient for
implementations to be discovered by the DI container. Implementations must
annotate their own concrete class with `@Named` and ensure
`DiIndexProcessor`
runs on their module.
### Affected interfaces
`LanguageProvider`, `LifecycleProvider`, `ModelParser`, `ModelTransformer`,
`PackagingProvider`, `PathScopeProvider`, `ProjectScopeProvider`,
`PropertyContributor`, `SettingsParser`, `TypeProvider`
This was identified during the review of #13647, which introduced a new
`LifecycleParticipant` SPI — that PR already has `@Named` removed from its
interface as a result of the same analysis.
---
- [ ] Your pull request should address just one issue, without pulling in
other changes.
- [x] Write a pull request description that is detailed enough to understand
what the pull request does, how, and why.
- [x] Each commit in the pull request should have a meaningful subject line
and body.
- [ ] Run `mvn verify` to make sure basic checks pass.
- [ ] You have run the [Core IT][core-its] successfully.
[core-its]: https://github.com/apache/maven-integration-testing
I hereby declare this contribution to be licensed under the [Apache License
Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]