Migrate 10 @Component classes to JSR330 in p2-maven-plugin
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:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
Migrate up to ten
@Componentannotated classes in p2-maven-plugin 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- A class can't use
@Singletonand@SessionScopedat the same time, don't add@Singletonif it already uses@SessionScopedin 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.
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
β¦