Goal: Make sense of command-line arguments from a Scala program
I like "scala-optparse", as it's simple. I tried a few others, first:
https://github.com/frugalmechanic/scala-optparse
Tuesday, October 25, 2011
Friday, October 21, 2011
Getting one big jar out of an sbt Scala project
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).
> 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).
Thursday, October 20, 2011
Subscribe to:
Comments (Atom)