1

We are using sbt-assembly to merge our dependent jars into a single jar file.

One of our dependencies contains native unmanaged dependencies for Windows, OSX and Linux. We will only be distributing on Linux. The native dependencies that we do not require are significantly increasing the size of our jar. The library is only provided as a single jar with all OS dependencies, not as separate jars for different native binaries.

Is there a way for me to filter these out during sbt-assembly?

EDIT
I am not trying to exclude an entire jar. One of the jar files that we are dependent on contains native binaries for Windows, OSX, and Linux. We need the jar file, we need the Linux binaries. We do not need the Windows or OSX binaries. They are doubling the size of the final single jar file.
We are using an assemblyMergeStrategy of "discard" for various other elements in the merged jars and this can reduce the size somewhat. The contents of the "lib" folder of the dependent jar do not seem to be being processed in that merge and discarded.

1 Answer 1

1

Manged to remove the native dependencies using the assemblyMergeStrategy.
The reason this didn't initially work is because I was trying to use a path in the pattern. If you want to use a path, use the PathList() (as documented here https://github.com/sbt/sbt-assembly#merge-strategy)

assemblyMergeStrategy in assembly := {
    case PathList("lib", "static", "Windows", xs @ _*) => MergeStrategy.discard
    case PathList("lib", "static", "Mac OS X", xs @ _*) => MergeStrategy.discard
    ...  
    case _ => MergeStrategy.first
}
1
  • You are right. The best way to exclude the class it's by using assemblyMergeStrategy. There used to be a excludedFiles in assembly option but it's not supported any more.
    – marios
    Commented Nov 23, 2015 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.