Skip to content

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

Merged
laeubi merged 3 commits into
mainfrom
copilot/migrate-to-jsr330-annotations
Oct 24, 2025
Merged

Migrate 10 @Component classes to JSR330 annotations in p2-maven-plugin#5514
laeubi merged 3 commits into
mainfrom
copilot/migrate-to-jsr330-annotations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 24, 2025

This PR migrates 10 @Component annotated classes in the p2-maven-plugin module from deprecated Plexus annotations to JSR330 annotations, continuing the effort tracked in #1494.

Migrated Classes

The following classes have been migrated:

  1. DefaultProvisioningAgentProvider - Implements IProvisioningAgentProvider
  2. MetadataIO - P2 metadata I/O utilities
  3. InstallableUnitSlicer - Computes dependency slices
  4. InstallableUnitPublisher - Publishes metadata using publisher actions
  5. SettingsDecrypterHelper - Decrypts Maven settings
  6. DefaultTransportCacheConfig - Transport cache configuration
  7. SharedHttpCacheStorage - HTTP cache storage implementation
  8. ProxyHelper - Maven proxy configuration helper
  9. MavenAuthenticator - HTTP/Proxy authentication handler
  10. InstallableUnitGenerator - Generates installable units from artifacts

Migration Pattern

Following the Plexus to JSR330 migration guide:

Plexus JSR330
@Component(role = X.class) @Named + @Singleton
@Requirement @Inject
@Requirement(hint = "...") @Inject + @Named("...")
Initializable.initialize() @PostConstruct

Changes

  • Replaced Plexus annotations with JSR330 equivalents in 10 classes
  • Converted Initializable lifecycle methods to @PostConstruct in 3 classes (ProxyHelper, DefaultTransportCacheConfig, MavenAuthenticator)
  • Removed throws InitializationException declarations (not needed with @PostConstruct)
  • Added javax.annotation-api dependency to pom.xml for @PostConstruct annotation support

Verification

  • ✅ Builds successfully with mvn clean install -T1C -DskipTests
  • ✅ The sisu-maven-plugin correctly generates META-INF/sisu/javax.inject.Named with all migrated classes
  • ✅ Formatting kept minimal to reduce diff size
  • ✅ Existing tests continue to cover migrated functionality

Notes

The @Inject annotation for Map<String, InstallableUnitProvider> in InstallableUnitGenerator follows the same pattern used throughout the codebase (e.g., in TychoProjectManager, ZipComparatorImpl, BndPluginManager). Sisu automatically collects all components of the specified type into the injected Map.

Related to #1494

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

This was already done as part of #5509 but we ommited it for easier review and checking for problems.

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

Migrated classes:
- DefaultProvisioningAgentProvider
- MetadataIO
- InstallableUnitSlicer
- ProxyHelper (Initializable -> @PostConstruct)
- SettingsDecrypterHelper
- DefaultTransportCacheConfig (Initializable -> @PostConstruct)
- SharedHttpCacheStorage
- MavenAuthenticator (Initializable -> @PostConstruct)
- InstallableUnitGenerator
- InstallableUnitPublisher

Changes:
- Replaced @component with @nAmed + @singleton
- Replaced @requirement with @Inject
- Replaced @requirement(hint=...) with @Inject + @nAmed("...")
- Replaced Initializable.initialize() with @PostConstruct
- Added javax.annotation-api dependency for @PostConstruct

Reference: #1494

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate @Component annotated classes to JSR330 annotations Migrate 10 @Component classes to JSR330 annotations in p2-maven-plugin Oct 24, 2025
Copilot AI requested a review from laeubi October 24, 2025 06:02
@laeubi laeubi marked this pull request as ready for review October 24, 2025 10:22
@github-actions
Copy link
Copy Markdown

Test Results

1 017 files  ±0  1 017 suites  ±0   6h 40m 14s ⏱️ + 38m 43s
1 304 tests ±0  1 283 ✅  - 1  20 💤 ±0  0 ❌ ±0  1 🔥 +1 
3 912 runs  ±0  3 848 ✅  - 1  63 💤 ±0  0 ❌ ±0  1 🔥 +1 

For more details on these errors, see this check.

Results for commit 8f4f799. ± Comparison against base commit b3d0b08.

@laeubi laeubi merged commit 57f78dd into main Oct 24, 2025
12 of 15 checks passed
@laeubi laeubi deleted the copilot/migrate-to-jsr330-annotations branch October 24, 2025 16:44
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