Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate fat JAR, with sbt-assembly or otherwise #13

Open
Oduig opened this issue Dec 20, 2022 · 1 comment
Open

How to generate fat JAR, with sbt-assembly or otherwise #13

Oduig opened this issue Dec 20, 2022 · 1 comment

Comments

@Oduig
Copy link

Oduig commented Dec 20, 2022

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?

@MasseGuillaume
Copy link

This project is aimed at publishing libraries with shaded jars and will modify the publish/publishLocal behavior. I agree that sbt-assembly should be a bit smarter to shade only transitive dependencies. You can always use .inAll in sbt-assembly to rewrite any class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants