Repository navigation
[MNG-8112] Honor export descriptors from the extension classpath - #13101
Conversation
Read package and artifact exports from maven.ext.class.path entries in both CLI implementations. Reuse descriptor discovery without moving extensions into the core realm or changing extension precedence. Cover JAR and directory entries, optional descriptors, package isolation, artifact filtering, and mixed extension loading with unit tests and Core ITs.
gnodet-bot
left a comment
There was a problem hiding this comment.
Solid fix. The approach correctly reads extension.xml descriptors from -Dmaven.ext.class.path entries and feeds their exported packages/artifacts into CoreExports, so ClassRealmManager can properly filter them when building plugin realms. Both CLI implementations (compat 3.x and impl 4.x) are semantically equivalent despite their structural differences. The ordering is correct — setupContainerRealm already adds the classpath URLs to the container realm before discoverFrom is called, so descriptor scanning works against the right classloader. The list mutation in PlexusContainerCapsuleFactory is safe because setupContainerRealm makes a defensive copy.
Test coverage is thorough: unit tests verify package export visibility, artifact filtering, optional descriptors, and multi-entry classpath merging. The integration tests exercise both classpath-only and classpath-plus-extensions.xml scenarios end-to-end.
One nit below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| @Deprecated | ||
| class MavenCliExtensionClasspathTest { |
There was a problem hiding this comment.
💡 Nit: @Deprecated marks this class itself as deprecated, which is not the intent — you want to suppress deprecation warnings from using the deprecated MavenCli. The correct annotation is @SuppressWarnings("deprecation").
| class MavenCliExtensionClasspathTest { | |
| @SuppressWarnings("deprecation") |
There was a problem hiding this comment.
@gnodet-bot Replaced @Deprecated with @SuppressWarnings("deprecation"). The CLI tests and module verification pass. Thanks for catching this.
Use SuppressWarnings instead of marking the regression test itself deprecated. Keep the warning suppression scoped to the test class.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after 79dfab82: the @Deprecated → @SuppressWarnings("deprecation") nit from the previous review has been addressed. No new issues introduced.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
Thanks for this contribution — this is exactly the right problem to fix. We've been discussing a broader classloader improvement plan for Maven 4.1 (tracked in #13223) and this PR is part of it. A few points from that discussion that affect how this should land:
Test should move to
Path deduplication When multiple entries on Once those are addressed this looks mergeable as Layer 3 of the overall plan. |
Drop the deprecated embedder changes and keep descriptor discovery in the active Maven CLI. Resolve classpath entries to real paths before processing while retaining the first spelling. Discover each descriptor independently so a malformed optional descriptor does not skip later valid exports. Cover relative and symlink aliases and malformed-first ordering.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after 00a67585: deduplication of maven.ext.class.path entries.
The toRealPath() + normalize() fallback correctly handles existing vs non-existent paths. The dedup gate fires on realPath while jars stores the original (uncanonicalised) path — that asymmetry is intentional and correct since ClassWorld doesn't care about path identity, only URL identity after addURL(file.toUri().toURL()).
The two new tests (processesEquivalentClassPathEntriesOnce, processesSymlinkedClassPathEntryOnce) are well-structured. The relative-path alias case correctly relies on context.cwd.resolve(alias) canonicalising back to the original absolute path before toRealPath().
Note for the record: MavenCli.parseExtClasspath() (compat layer) still lacks the equivalent deduplication. This is a pre-existing gap — the compat layer is deprecated, and the new commit is deliberately scoped to impl/maven-cli ("active CLI") — so it's not a blocker. Worth addressing separately if compat users report issues.
No new issues introduced.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
Thanks @gnodet. I removed the deprecated |
Fixes #10506.
Discover
META-INF/maven/extension.xmlfrommaven.ext.class.pathin the active Maven CLI (impl/maven-cli) and include package and artifact exports inCoreExports. Exported packages become visible to plugins, and exported artifacts are filtered from plugin dependencies. The deprecatedcompat/maven-embedderchanges have been removed.Reuse the existing descriptor reader and preserve extension classloader isolation. Deduplicate classpath entries by real path before processing, retaining the first entry. Discover each descriptor separately so a malformed optional descriptor cannot skip later valid entries. Tests cover JARs, directories, relative and symlink aliases, malformed descriptors, and loading alongside
.mvn/extensions.xml.Validation: the classpath Core IT regressions failed against the unmodified distribution in the original PR work and pass with this fix. On the current head,
mvn -B -ntp verifypassed, all 11PlexusContainerCapsuleFactoryTestcases passed, andmvn -B -ntp -Prun-its -Dits.test=MavenITmng5771CoreExtensionsTest -Dits.forkCount=2 verifypassed (7 Core IT cases). The full Core IT suite passed on the earlier PR revision, before this follow-up.Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.