Scala, sbt: create a fat JAR

Environment:

  • Scala: 2.13.1
  • sbt: 1.3.8

Create a fat JAR in a Scala sbt project:

1. Create a new file assembly.sbt in project (sources root) folder

2. Add a sbt-assembly plugin by adding the following line to the assembly.sbt file:

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

3. Specify the assembled JAR name in the build.sbt file:

assemblyJarName in assembly := "yourJar.jar"

4. Start sbt shell and execute assembly command

Fat JAR is created in the target/scala-2.13 folder