[MNG-8112] extension.xml is ignored when extension is loaded by -Dmaven.ext.class.path
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Rich DiCroce](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rdicroce)** opened **[MNG-8112](https://issues.apache.org/jira/browse/MNG-8112?redirect=false)** and commented
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:
1. 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()).
2. 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.
---
**Affects:** 3.9.6
**Attachments:**
- [image-2025-02-24-13-07-19-735.png](https://issues.apache.org/jira/secure/attachment/13074952/image-2025-02-24-13-07-19-735.png) (_44.17 kB_)
Contributor guide
Research direction
Start in org.apache.maven.cli.MavenCli, especially setupContainerRealm(), parseExtClasspath(), and loadCoreExtensions(), and compare the m2.conf handling of lib/ext extensions. Reproduce loading an extension with -Dmaven.ext.class.path and verify whether extension.xml is processed and additional packages are exposed; if the methods are intentionally different, update the guide using extensions documentation instead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100