Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Package relocation doesn't relocate references in project source. Results in NoClassDefFound. #55
To achieve this I specify shadowJar task as following:
I hope I'm right, that that should be it, i.e. all my classes in my jar, that used com.google.* classes, are now "rewritten" to use mycompany.com.google.* classes.
When I unpacked the jar, I see that indeed all com.google classes landed in mycompany/com/google directory. There are empty directories in com/google, but I believe this is not the issue.
I can confirm this issue with Java 7 as well. The dependency (Guava in this case) is relocated correctly and all references in the dependency will be relocated to their new path.
I have not tested it with Java 8, but maybe you can update ASM to version 5 in the plugin if the older versions do not support Java 8?
Exactly, I was just writing my comment about this:) As I believe shadowJar relocates the references inside the dependencies jars. But it does not relocate the references inside the class files of the project it is defined in (as you named it "source of the project").
So now I need to understand how to relocate references in the source of the project. One workaround would be to generate jar out of it first and then make shadowJar out of all jars including the one from sources.
If you need it now I think you could use the older version of the shadow plugin (0.8). It works a little bit different and the new version is easier and faster to use but the relocation is working properly with it (Java 7, you need to test if you can get it working with Java 8).
changed the title from
getting NoClassDefFoundError after relocating package
Package relocation doesn't relocate references in project source. Results in NoClassDefFound.
Jun 27, 2014
@kzarzycki v0.8 won't support zip64, that was one of the driving factors for the re-write in 0.9.0.
Thanks John, Minecrell!
John, that's very good that you got a fix already, I'll wait for the new version of your awesome plugin:)
Unfortunately, it seems there will be another issue that is now related to JDK8, lambdas & asm 5.x. As I believe it's more an issue of asm than shadow, I have just submitted a bug on OW2 asm issue tracker:
But it also might be an issue of how you use asm in shadow, so I wanted to submit an issue for you too.
It should help you jump right to the problem. I'll be gratefull if you could look into that.