Migrate Plexus @Component annotations to JSR330 in 9 modules (excluding tycho-core, demo, tycho-its, p2-maven-plugin, tycho-packaging-plugin, tycho-versions-plugin)
This PR migrates org.codehaus.plexus.component.annotations.Component annotated classes to JSR330 annotations (javax.inject.*), following the deprecation of Plexus annotations in favor of JSR330 as documented in the Plexus to JSR330 migration guide.
Scope
This migration covers 20 production Java files across 9 modules, excluding tycho-core, demo, tycho-its, p2-maven-plugin, tycho-packaging-plugin, and tycho-versions-plugin which will be handled separately:
- tycho-build (3 files)
- tycho-source-plugin (3 files)
- tycho-apitools-plugin (2 files)
- tycho-baseline-plugin (2 files)
- tycho-bnd-plugin (3 files)
- tycho-eclipse-plugin (1 file)
- tycho-p2-publisher-plugin (2 files)
- tycho-repository-plugin (2 files)
- tycho-sbom (2 files)
Changes
Annotation Replacements
-
@Component → @Named + @Singleton
// Before @Component(role = SomeService.class, hint = "default") public class DefaultSomeService implements SomeService { } // After @Named("default") @Singleton public class DefaultSomeService implements SomeService { } -
@Requirement → @Inject
// Before @Requirement private Logger logger; // After @Inject private Logger logger; -
@Requirement(hint="x") → @Inject + @Named("x")
// Before @Requirement(hint = "custom") private SomeService service; // After @Inject @Named("custom") private SomeService service; -
Per-lookup components (omit
@Singletonfor non-singleton lifecycle)// Before @Component(role = X.class, instantiationStrategy = "per-lookup") // After @Named
Build Configuration
Added sisu-maven-plugin to 7 affected pom.xml files to generate the required META-INF/sisu/javax.inject.Named index files for component discovery.
Testing
- ✅ Full build succeeds:
mvn clean install -T1C -DskipTests - ✅ All META-INF/sisu/javax.inject.Named files generated correctly
- ✅ No compilation errors across all migrated modules
- ✅ Existing tests cover the migrated code (no new tests required)
Notes
- Formatting changes kept minimal to reduce diff size
- Existing
@SessionScopedannotations preserved where present - Test files intentionally not migrated as they don't affect production behavior
-
p2-maven-plugin,tycho-packaging-plugin, andtycho-versions-pluginexcluded from this PR to keep the workload manageable and will be handled separately - This PR contributes to #1494 but does not close it, as
tycho-core,demo,tycho-its, and the excluded modules require separate handling
Relates to #1494
Original prompt
Migrate all remaining
org.codehaus.plexus.component.annotations.Componentannotated classes except in in tycho-core, the demo or tycho-its to JSR330 annotationsPlexus
@Componentannotations are deprecated replaced by plain JSR 330 components see https://github.com/eclipse/sisu.plexus/wiki/Plexus-to-JSR330For this we want:
- Migrate any currently
@Componentannotated components to JSR330- if a component currently does not implement an interface extract an intermediate interface and rename the previous one to
Default<NameOfClass>- Make sure
@Namedis always added to all components as it is required by maven, and@Singeltonwhen it is a component that do not uses per-lookup strategy- Keep formatting of the source files as close as possible to have smaller diffs
- We do not need any tests for this change as existing test will cover the case
- Make sure everything compile using
mvn clean install -T1C -DskipTestsin the root of the repository (skips all tests and integration test for fast verification)- Add a reference to https://github.com/eclipse-tycho/tycho/issues/1494 to link the PR with the ongoing effort but not close it.
- Make sure the
sisu-maven-pluginis activated in thepom.xmlto generate the filetarget/classes/META-INF/sisu/javax.inject.Named- Use
@PreDestroyon method whereDisposablewas previously implemented- If a component is using a base class and that baseclass has fields that are injected with
@Requirementthis baseclass and all its extensions need to be converted as well- tycho-core, demo and tycho-its should be ommited from this search as we need to handle them seperatly
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
@copilot we exclude p2-maven-plugin (41 files), tycho-packaging-plugin (10 files) and tycho-versions-plugin (12 files) for now to keep the workload managable here!
@copilot we exclude p2-maven-plugin (41 files), tycho-packaging-plugin (10 files) and tycho-versions-plugin (12 files) for now to keep the workload managable here!
Reverted the changes for p2-maven-plugin (41 files), tycho-packaging-plugin (10 files), and tycho-versions-plugin (12 files) in commit ab9131d. The PR now migrates only 20 files across 9 modules.