tycho icon indicating copy to clipboard operation
tycho copied to clipboard

Migrate 10 @Component classes to JSR330 in p2-maven-plugin

Open Copilot opened this issue 4 months ago β€’ 1 comments

Migrates 10 Plexus @Component annotated classes to JSR330 annotations as part of the ongoing effort to modernize dependency injection across Tycho modules.

Related to https://github.com/eclipse-tycho/tycho/issues/1494

Changes

Simple components (no dependencies):

  • P2ArtifactRepositoryLayout, P2RepositoryConnectorFactory
  • EclipseTargetDefinitionArtifactHandler, EclipseTestPluginArtifactHandler
  • P2ArtifactsArtifactHandler, P2InstallableUnitArtifactHandler, P2MetadataArtifactHandler

Components with dependencies:

  • DefaultProvisioningAgent - field injection with named qualifiers
  • P2ServicesLifecycleListener - map injection
  • DefaultMavenRepositorySettings - Initializable β†’ @PostConstruct

Migration pattern

// Before
@Component(role = IProvisioningAgent.class)
public class DefaultProvisioningAgent implements IProvisioningAgent {
    @Requirement
    private Logger log;
    
    @Requirement(hint = "connect")
    private EquinoxServiceFactory serviceFactory;
}

// After
@Named
@Singleton
public class DefaultProvisioningAgent implements IProvisioningAgent {
    @Inject
    private Logger log;
    
    @Inject
    @Named("connect")
    private EquinoxServiceFactory serviceFactory;
}

Plexus component count: 23 β†’ 13
JSR330 components indexed by sisu-maven-plugin: +10

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • testng.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/tycho/.codeql-scratch/dbs/java/working/files-to-index15537833322444320745.list --sourceArchiveDir=/home/REDACTED/work/tycho/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/tycho/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Migrate up to ten @Component annotated classes in p2-maven-plugin 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 https://github.com/eclipse-tycho/tycho/issues/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. A class can't use @Singleton and @SessionScoped at the same time, don't add @Singleton if it already uses @SessionScoped in that case.

πŸ’‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 25 '25 16:10 Copilot

Test Results

 30 files   -β€Šβ€‡β€ˆ948   30 suites   -β€Š948   17s ⏱️ - 5h 53m 37s  57 tests  -β€Š1β€ˆ247   57 βœ…  -β€Š1β€ˆ227  0 πŸ’€  -β€Š20  0 ❌ Β±0  171 runsβ€Š  -β€Š3β€ˆ649  171 βœ…  -β€Š3β€ˆ588  0 πŸ’€  -β€Š61  0 ❌ Β±0 

Results for commit a54a7d7b. ± Comparison against base commit 7e7ede6d.

This pull request removes 1247 tests.
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDifferentVersions[includeSource=false]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDifferentVersions[includeSource=true]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDirectAndTransitivRequirement[includeSource=false]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDirectAndTransitivRequirement[includeSource=true]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDirectRequirement[includeSource=false]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfDirectRequirement[includeSource=true]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfMultipleVersions[includeSource=false]
org.eclipse.m2e.pde.target.tests.DependencyExclusionTest ‑ testExclusionOfMultipleVersions[includeSource=true]
org.eclipse.m2e.pde.target.tests.MavenContentTest ‑ testIncludeProvidedInfinite
org.eclipse.m2e.pde.target.tests.MavenContentTest ‑ testJettyWithInDependencies
…

github-actions[bot] avatar Oct 26 '25 05:10 github-actions[bot]