Goal: Get a jar that includes all the dependencies of a Scala SBT project, so I can run
> java -jar MyAwesomeApplication.jar
instead of running through SBT (slow).
I used
https://github.com/eed3si9n/sbt-assembly
with the following configuration in build.sbt:
"""
import AssemblyKeys._ // put this at the top of the file
seq(assemblySettings: _*)
// Remove cryptographic bullshit that can make Java security freak out.
// Even though we "remove" the manifest, a manifest still ends up in the
// jar, so it looks like another is generated. If we don't remove it, we get a
// complaint about multiple manifests.
excludedFiles in assembly := { (bases: Seq[File]) =>
bases flatMap { base =>
(base / "META-INF" * "*").get collect {
case f if f.getName.toLowerCase.contains(".rsa") => f
case f if f.getName.toLowerCase.contains(".dsa") => f
case f if f.getName.toLowerCase.contains(".sf") => f
case f if f.getName.toLowerCase == "manifest.mf" => f
}
}}
"""
I had to remove the cryptographic keys (what I'm doing above) because I was getting a java.lang.SecurityException, so I adapted the suggestions on this site:
http://www.corba.at/index.php?m=11&y=09&d=23&entry=entry091123-213409
Thank you, Google translate!
Also, I tried
https://github.com/retronym/sbt-onejar first, but without success (it seems to use an outdated version of One-JAR).