Skip to content
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

Usage with mavend and multi-module poms #312

Open
floverfelt opened this issue Aug 19, 2024 · 1 comment
Open

Usage with mavend and multi-module poms #312

floverfelt opened this issue Aug 19, 2024 · 1 comment

Comments

@floverfelt
Copy link

We use GMavenPlus extensively in our project and I was attempting to update the project to use mavend. However, I ran into this issue: apache/maven-mvnd#900

Basically, attempting to run mvnd clean install twice in a row failed.

After a lot of debugging, the root cause is the GMavenPlus plugin's class loader. If you create a multi module project where module B depends upon module A and add any execution of the GMavenPlus plugin's execute goal to module B, the subsequent build will fail to clean. This is because (as far as I can tell) GMavenPlus overrides the class loader in the Thread with a custom class loader: https://github.com/groovy/GMavenPlus/blob/master/src/main/java/org/codehaus/gmavenplus/util/ClassWrangler.java#L74

That class loader is holding a lock on the target/ dir's jar of module A since it is a dependency of module B when module B's build executes. This is fine in typical maven since that lock is released when the execution finishes. However, in mavend, that Thread/class loader is cached across builds which causes subsequent cleans to fail. The fix for this to simply specify PLUGIN_ONLY here: https://groovy.github.io/GMavenPlus/execute-mojo.html#includeClasspath

That way module A's jar isn't included on the class path of the plugin by default. Of course, if you need module A in GMavenPlus' execution, I'm not sure how you'd work around this.

Repo with a reproduction: https://github.com/floverfelt/gmavenplus-mavend-example/tree/main

Run mvnd clean install twice in a row on that (using Windows, mvnd 1.0.1) and the issue should appear with error:

Failed to clean project: Failed to delete \module-rest\module-api\target\module-api-1.0-SNAPSHOT.jar 

I'm not sure how that jar is getting on the class path to be locked, it should be coming from the Maven repository, not the local project?

Anyway, I realize this is a highly specific issue and I don't expect a fix, but thought I'd share for anybody else who runs into this.

@keeganwitt
Copy link
Member

Thanks for reporting this! I'm not sure offhand if there's anything I can do, but I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants