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
Groovy class loaders are not independent between modules #183
Comments
I haven't seen the behavior explicitly documented. This is all I could find: http://takari.io/book/91-maven-classloading.html. I'm doing some experiments to understand better. |
By the way, this doesn't happen when using At the moment, I believe the parent classloader is the classloader from the Plexus ClassRealm. It appears this parent is reused for both goal executions, and that's why it seems to be additive (whichever one runs second has both depedencies), even if I create another classloader within the mojo's |
Fix multi-module classpath issues (closes #183)
Thank you very much for the fix 👍🏽 I'll probably be able to test it after the holidays. |
Thanks for reporting this (and for providing the test case)! I just made a release with this fix (1.12.0). |
I'm currently not sure if this is a bug or just a "This is how Java works, deal with it" problem, so feel free to close this if this "works as intended".
When running scripts in multiple independent maven modules under the same parent, the class loaders are not independent. I have attached a ZIP with a minimal reproducer (gmavenplus-test.zip):
a
has a dependency on log4jb
has a dependency on junitAll modules run a script which simply does
Class.forName()
for both, a class from log4j and a class from junit. The result is what you expect for whatever module runs first, but classes are found from both modules in whichever module is run last.This surprised me a bit. I was under the impression that the "temporary" class loader which this plugin uses is destroyed after each run (or at least after each maven module)
The text was updated successfully, but these errors were encountered: