Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

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

  1. @component@nAmed + @singleton

    // Before
    @Component(role = SomeService.class, hint = "default")
    public class DefaultSomeService implements SomeService { }
    
    // After
    @Named("default")
    @Singleton
    public class DefaultSomeService implements SomeService { }
  2. @requirement@Inject

    // Before
    @Requirement
    private Logger logger;
    
    // After
    @Inject
    private Logger logger;
  3. @requirement(hint="x") → @Inject + @nAmed("x")

    // Before
    @Requirement(hint = "custom")
    private SomeService service;
    
    // After
    @Inject
    @Named("custom")
    private SomeService service;
  4. Per-lookup components (omit @Singleton for 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 @SessionScoped annotations preserved where present
  • Test files intentionally not migrated as they don't affect production behavior
  • p2-maven-plugin, tycho-packaging-plugin, and tycho-versions-plugin excluded from this PR to keep the workload manageable and will be handled separately
  • This PR contributes to Replace Plexus Components by plain JSR 330 Components #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.Component annotated classes except in in tycho-core, the demo or tycho-its to JSR330 annotations

Plexus @Component annotations are deprecated replaced by plain JSR 330 components see https://github.com/eclipse/sisu.plexus/wiki/Plexus-to-JSR330

For this we want:

  1. Migrate any currently @Component annotated components to JSR330
  2. if a component currently does not implement an interface extract an intermediate interface and rename the previous one to Default<NameOfClass>
  3. Make sure @Named is always added to all components as it is required by maven, and @Singelton when it is a component that do not uses per-lookup strategy
  4. Keep formatting of the source files as close as possible to have smaller diffs
  5. We do not need any tests for this change as existing test will cover the case
  6. Make sure everything compile using mvn clean install -T1C -DskipTests in the root of the repository (skips all tests and integration test for fast verification)
  7. Add a reference to Replace Plexus Components by plain JSR 330 Components #1494 to link the PR with the ongoing effort but not close it.
  8. Make sure the sisu-maven-plugin is activated in the pom.xml to generate the file target/classes/META-INF/sisu/javax.inject.Named
  9. Use @PreDestroy on method where Disposable was previously implemented
  10. If a component is using a base class and that baseclass has fields that are injected with @Requirement this baseclass and all its extensions need to be converted as well
  11. 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.

@laeubi
Copy link
Member

laeubi commented Oct 23, 2025

@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 AI and others added 4 commits October 23, 2025 08:15
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
…ipse, p2-publisher, repository, sbom)

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
…e migration

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate Plexus component annotations to JSR330 Migrate all remaining Plexus @Component annotations to JSR330 (except tycho-core, demo, tycho-its) Oct 23, 2025
Copilot AI requested a review from laeubi October 23, 2025 08:37
…lugin from migration

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@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.

Copilot AI changed the title Migrate all remaining Plexus @Component annotations to JSR330 (except tycho-core, demo, tycho-its) Migrate Plexus @Component annotations to JSR330 in 9 modules (excluding tycho-core, demo, tycho-its, p2-maven-plugin, tycho-packaging-plugin, tycho-versions-plugin) Oct 23, 2025
@laeubi laeubi marked this pull request as ready for review October 23, 2025 09:07
Copy link
Member

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants