Build using 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")
  1. Specify the assembled JAR name in the build.sbt file:
assemblyJarName in assembly := "yourJar.jar"
  1. Start sbt shell and execute assembly command

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

Resolve postfix operator needs to be enabled error

Environment:

  • Scala: 2.13.1
  • sbt: 1.3.8

An error: postfix operator needs to be enabled by making the implicit value scala.language.postfixOps visible can be resolved by adding the following line to the build.sbt file:

scalacOptions ++= Seq(
  "-language:postfixOps"
)