New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNG-7160] Ability to customize core extensions classloaders #616
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this change looks kinda okay, but also not okay, here is why:
- before change it was delegated, but as core extension realm has no imports applied to it (!), it really has no effect is it "base" realm (parent class-loader in java lingo, no filtering) or "parent" realm (delegates via strategy, filtering applies if set).
- but
CoreExports
(and corresponding XML file) seems was never applied/used in core extension realm?
This looks something either I am missing, or is simply missing?
Not really, when no imports are specified for the parent realm, the realm has full visibility on its parent.
The xml extension is not used, that's right.
Yes, what this commit does is to simply change from self-first to parent-first class loading, that's all. This avoids the If this change is not acceptable for compatibility reason, one possibility would be to extend the extension model to be able to specify self-first or parent-first strategy as an xml attribute on the extension. |
This makes sense to me, just to repeat: core extension (had) have "unfiltered" access to maven being extended, along with all the classes being present in maven-core realm. Essentially, this is the case even today (no CoreExports applied), but due SelfFirst strategy CCEx happend? And after this change will not. |
Yes, that's it. |
Change looks good to me but can be great to test some more real world extensions (the ones I tested don't abuse of dependencies enough). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the projects you're testing that demonstrate the Xpp3Dom loading issue? For any extensions I've made that used core dependencies I've marked as provided and I don't have any issues. But in your case you are not marking them as provided and this is when you see the CCE? That's why I just wanted to look at your setup, as it seems like it's the same thing being done in Provisio where there's no issue with 3.x.
Ah, I think the problem comes from the way the extension's artifacts are resolved. When I put the |
Using the assembly plugin? |
No, the artifacts list comes from https://github.com/apache/maven/blob/master/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java#L139 |
5bb43e2
to
1c6e732
Compare
I've rewritten the PR to allow the user to choose the class loading strategy and added an integration test (apache/maven-integration-testing#125) showing the 4 possibilities and the differences in class loading. I'm not sure if the fact that even when a dependency with an explicit |
I know you've gone through the effort here to get the caching extension to work from I realize the way extensions in |
Currently, they do not work exactly the same. Some beans are discovered a bit too early in the process. For example The new |
maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java
Outdated
Show resolved
Hide resolved
maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java
Outdated
Show resolved
Hide resolved
maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java
Outdated
Show resolved
Hide resolved
maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going into 3.9.0, make sure to adjust the IT too.
Since apache/maven#616, the default CoreExportProvider no longer uses the provided CoreExports, but instead tries (and fails) to discover them itself. This change fixes that by providing our own custom instance of CoreExportProvider. This allows core extension to contribute exported artifacts and exported packages again, like it used to do before the Maven 4.x upgrade.
* Fix core export provider Since apache/maven#616, the default CoreExportProvider no longer uses the provided CoreExports, but instead tries (and fails) to discover them itself. This change fixes that by providing our own custom instance of CoreExportProvider. This allows core extension to contribute exported artifacts and exported packages again, like it used to do before the Maven 4.x upgrade. * Add integration tests for API-providing extensions
) (cherry picked from commit 115febf)
JIRA issue: https://issues.apache.org/jira/browse/MNG-7160
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe 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.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.