How can I deploy a shadowed jar to a Maven repository?

I am building a project that makes use of ASM and I am therefore using the Shadow plugin for repackaging the dependency into my name space. This works fine. In the end, I need two builds, one with the original dependencies and one with the imported dependencies.

However, I am running into a problem:

The Shadow plugin is apparently not capable of building source code and javadoc artifacts that respect the namespace change. I wonder if there exists an alternative.

I saw that other projects like Mockito “solved” this problem by manually repackaging the dependency: - I hope that I can avoid this.

Is there a plugin that actually rearranges the source code before compiling? This would allow for the creation of any artifact that derives from the latter and it would allow for some sort of validation on compilation.

I looked at the Shadow plugin’s source code which is actually a one to one copy of the Maven Shade plugin and it rearranges the imports by replacing the corresponding values in the constant pool. This would actually lead to Strings being renamed as well since they are shared in the constant pool so this is a rather hacky aproach.

Thanks for any hints!

I’ve never heard of a shadowing plugin that works on the source code level, and it’s not clear to me how this would work. If you truly need this, you are probably best off with the Mockito approach. Unless the shadowed library is part of your project’s public API (which is unlikely for ASM), I don’t see much of a reason for the Javadoc and sources Jars to reflect the namespace change.

The Maven Shade plugin knows how:

I want to add the sources such that it is easier for users to navigate through my framework’s stack trace where they might of course hit ASM somewhere. It’s not a big thing, but I would prefer it for deployment.