ScalaMan
ScalaMan

Reputation: 61

SBT Compile for uber jar

What is the best way to make a SBT project work in offline environment? There is any ways to compile it outside (in network env), e.g uber jar with all its dependencies, and then in the offline env just run it?

For example in Java Maven, We can compile it with uber jar with all dependencies, and then in the offline env just java -jar MyJar.jar ...

Thanks.

Upvotes: 1

Views: 521

Answers (1)

Levi Ramsey
Levi Ramsey

Reputation: 20561

Best bet for creating an uber/fat jar is the sbt assembly plugin. Include it in your project by putting something like the following in project/assembly.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")

Then just running sbt assembly should create a jar with all the dependencies in target/scala_$SCALA_VERSION. You may need to designate a main class for the jar if you want to run it with java -jar (as opposed to java -cp $jarfile $mainclass):

mainClass in assembly := Some("package.mainClass")

Upvotes: 1

Related Questions