What is the best way to set the target package for an SBT project to be an executable jar file?
It would need to bundle scala-library.jar and set the manifest for main-m
Use the assembly-sbt plugin (originally created by Coda Hale, now maintained by Eugene Yokota): https://github.com/sbt/sbt-assembly
Once you add this to your project it will build a so-called "fatjar" which is executable via java -jar projectName-assembly.jar
. It will autodetect your main method -- if there is more than one in your source, you can explicitly set which one to use by setting mainclass
, e.g.:
mainClass in assembly := Some("com.package.ClassNameWithMain")
Note: I edited this answer to be up-to-date with the current release of SBT (0.11+).