When a library is released it's very common for the author to provide the Maven/Gradle dependencies. If the library needs to be shaded, they would also specify the relevant package for the shade plugin:
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>${shade.base}.inventoryframework</shadedPattern>
</relocation>
But what if they don't? For many dependencies I had to search the github page for the top package, which of course can be wrong. What should I do at that case?
- If it's not clear from the post, I need to create a stand-alone jar(a plugin for a certain system) that contains my dependencies to obviously avoid
ClassNotFoundException
s at runtime.
Thing is, you "usually" don't shade your dependencies. This is why information about this is often not provided, and you are on your own.
There are actually few reasons to shade.
If you build a standalone JAR, and you find a conflict in your transitive dependencies, you first try to fix it without shading:
<dependencyManagement>
to some new version and test if it works.Only if this does not work, you start shading.
Note: I am talking about standalone JARs. If your JAR runs as a plugin in the context of a different class loader (together with other, unknown plugins) like in Jenkins, then it might be worthwhile to shade a lot of stuff, and to reduce dependencies to an absolute minimum.