[ https://issues.apache.org/jira/browse/MNG-8112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17929475#comment-17929475 ]
Christoph Läubrich commented on MNG-8112: ----------------------------------------- Same behavior / problem on {code}Apache Maven 4.0.0-rc-2 (273314404f85ec3c089e295d8b4e0cb18c287cf5){code} I use this in my {code}META-INF/maven/extension.xml{code}: {code}<extension> <exportedPackages> <exportedPackage>org.codehaus.plexus.build</exportedPackage> </exportedPackages> <exportedArtifacts> <exportedArtifacts>org.codehaus.plexus:plexus-build-api</exportedArtifacts> </exportedArtifacts> </extension>{code} When the plugin is added with {code}.mvn/extensions.xml{code} then it is replaced on other mojos and I got this print out: > [INFO] [stdout] Event listener created by > ClassRealm[coreExtension>org.codehaus.plexus:plexus-build-api:1.2.1-SNAPSHOT, > parent: ClassRealm[plexus.core, parent: null]] When I use instead {code}-Dmaven.ext.class.path=...{code} then it is not replaced in classpath of mojos and I get > [INFO] [stdout] Event listener created by ClassRealm[maven.ext, parent: > ClassRealm[plexus.core, parent: null]] If I use both ({code}.mvn/extensions.xml{code} and {code}-Dmaven.ext.class.path=...{code}) then I get it two times: > [INFO] [stdout] Event listener created by > ClassRealm[coreExtension>org.codehaus.plexus:plexus-build-api:1.2.1-SNAPSHOT, > parent: ClassRealm[plexus.core, parent: null]] > [INFO] [stdout] Event listener created by > ClassRealm[coreExtension>org.codehaus.plexus:plexus-build-api:1.2.1-SNAPSHOT, > parent: ClassRealm[plexus.core, parent: null]] My expectation would be: # It replaces the jar in the mojos classpath regardless of what technique is used # If it is used in multiple places then {code}-Dmaven.ext.class.path=...{code} takes precedence over {code}.mvn/extensions.xml{code} > extension.xml is ignored when extension is loaded by -Dmaven.ext.class.path > --------------------------------------------------------------------------- > > Key: MNG-8112 > URL: https://issues.apache.org/jira/browse/MNG-8112 > Project: Maven > Issue Type: Bug > Components: Class Loading > Affects Versions: 3.9.6 > Reporter: Rich DiCroce > Priority: Major > > As the title says: extension.xml is ignored when an extension is loaded by > -Dmaven.ext.class.path, which makes it impossible to expose any additional > packages. > I am filing this as a bug due to [this > comment|https://issues.apache.org/jira/browse/MNG-6906?focusedCommentId=17719869&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17719869] > on MNG-6906, which says that lib/ext and -Dmaven.ext.class.path are supposed > to be synonymous. Note that MNG-6906 is a related but different problem. > When looking at org.apache.maven.cli.MavenCli, the problems aren't too hard > to see: > # lib/ext extensions get loaded into the plexus.core realm (as per m2.conf), > but -Dmaven.ext.class.path extensions are loaded into the maven.ext realm (as > per MavenCli#setupContainerRealm()). > # loadCoreExtensions() operates on the coreRealm, but due to #1, the > extensions are not in that realm. Also, the result of parseExtClasspath() is > not passed to loadCoreExtensions(), so there is no way for > loadCoreExtensions() to find the relevant files. > The most obvious solution would be to call coreRealm.addURL() for each of the > files discovered by parseExtClasspath(). This would solve #1 above which > would implicitly fix #2. Though I don't know if it would have other > consequences. > If this is not a bug and is instead "works as designed", then > [https://maven.apache.org/guides/mini/guide-using-extensions.html] needs to > be updated to explain that the three methods of loading core extensions are > not equivalent. -- This message was sent by Atlassian Jira (v8.20.10#820010)