How to package a Scala project to a .jar with sbt?
Posted on In QAHow to package a Scala project to a .jar file with sbt? Manually packaging the .class files are fine but too tedious.
A jar of just the project classes
The command:
sbt package
will produces the main artifact as a jar into target/scala-2.x.y/project_name_2.x.y-zz.jar
.
Continuously building the package:
sbt ~package
Standalone jar with all dependencies
If you want to build a standalone executable jar with dependencies, you may use the sbt-assembly plugin. And then build it by
sbt assembly
The standalone will be in target/project_name-assembly-x.y.jar.
You can run it by
java -jar project_name-assembly-x.y.jar [class.with.main.function]