Reputation: 8181
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.
Upvotes: 1
Views: 727
Reputation: 8181
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
}
Upvotes: 1