sbt-shading
sbt-shading copied to clipboard
How to generate fat JAR, with sbt-assembly or otherwise
Background
In our project we are using sbt-assembly
to generate a fat JAR for Spark. Our Spark deployment has a very large body of libraries built-in, which are often out of date and conflict with libraries in our own project. We regularly run into the cryptic error java.lang.VerifyError: Cannot inherit from final class
which points to a dependency conflict. To solve this, we manually go through the dependency tree to find the conflicting classes, and shade them by class package.
This is especially tiresome for large dependencies which pull in nested dependencies. It would be better to shade by library rather than by class package, and it appears sbt-shading
perfectly solves that problem!
Question
When I run sbt assembly
, the project is built as normal, and none of the libraries in shadedModules
are shaded.
Can we use sbt-shading
with sbt-assembly
somehow? Alternatively, what is the best way to create a fat JAR with sbt-shading
?