Reputation: 2049
In my build process, I need to shade twice. Why I do this is not really relevant to the question, but here is the reason: because I first shade my own dependencies, then I obfuscate this first fat jar, and then I want to shade the third party dependencies too.
Firs difficulty was to have the goals run in the correct order. By default, if everything happens at the packaging phase (which would seem rather logical) both shades are performed in a row, and obfuscation is performed afterwards. I managed to tweak the maven phases so the goals execute in the correct order, but now I am stuck, because it seems that:
maven-jar-plugin
Thus I end up with one obfuscated partially-shaded jar, and one fully-shaded not obfuscated jar.
I could not find relevant option to force a particular source jar to the shade configuration. Shade documentation does not give clues. I suppose I may solve my problem by performing everything in place but I had rather not.
Upvotes: 1
Views: 276
Reputation: 14951
I did a brief scan of the source code and indeed, it doesn't look like it's possible to specify the input jar in the configuration, as of plugin version 3.2.1. The error message around line 550 specifically mentions a requirement on the jar from the jar
plugin. There are some open issues that seem to be requesting something similar.
After checking the docs though, I wonder if you could configure things to keep overwriting the main jar (target/my-artifact-1.0.0.jar
). In other words, configure both the first shade execution and the obfuscation to direct output to that file. Then, the second shade execution will have the right input. The downside to this approach is there will be no intermediate files to analyze if something goes wrong.
Perhaps writing a custom transformer as suggested in the comments to MSHADE-304 is a better idea for this case.
Upvotes: 1