Building Scala Projects for Ignorants


As you know I am a rather .NET-orientated developer but with adoption of Kafka you realise lots of tools are written in Java or Scala. This time I needed to get built and deployed Remora - a Kafka lag monitoring tool from Zalando. In the Docker world you’d just use the provided Docker image. However, if you want an old-fashioned deployment you need to build it yourself.

You need to understand a couple of things before building Scala projects.

I’ve been running my stuff on Windows Linux Subsystem with Ubuntu.

You need a JVM installed in order to compile or run Scala projects.

Make sure your setup meets the requirements of Scala and JVM Compatibility. You can have multiple versions of JDK installed and switch between them using update-java-alternatives.

You need to get it installed.

If you want to have a single self-contained JAR you need to use sbt assembly.

sbt clean assembly

Assuming you’re in the directory where build.sbt is located. (Usually project’s root).

sbt 'set assemblyOutputPath in assembly := new File("path/to/my.jar")' clean assembly
sbt 'set test in assembly := {}' clean assembly
sbt 'set assemblyOutputPath in assembly := new File("some.jar")' \
'set test in assembly := {}' clean assembly

And that’s it. Happy building!