Scala Build Tooling

Faster Scala Builds with bloop and coursier

One common complaint about Scala is the long time lag for compiles, running tests and starting up Scala programs. Another challenge about dependency management in general is the use of libraries depending on other libraries etc. that all must be downloaded.

Enter the Scala Center’s bloop build server to reduce compile, test and run times and the coursier sbt plugin to parallelize library dependency downloads with an all Scala dependency management tool.

Bloop server

The Bloop server as supports the build server protocol (bsp) that allows integration with the IntelliJ Idea IDE and integrates with sbt, Maven, Gradle and Mill.

Ubuntu Install

# Installs to $HOME/.bloop
curl -L | python

# Add bloop to PATH in .bashrc

# Add autocompletion ~/.bash_profile
. $HOME/.bloop/bash/bloop

Start/Stop via systemd

systemctl --user enable $HOME/.bloop/systemd/bloop.service
systemctl --user daemon-reload
journalctl --user-unit bloop
systemctl --user status bloop
systemctl --user start bloop # also stop/restart

sbt integration

# ${PROJECT_ROOT}/project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.3.2")

> bloopInstall #re-run when changing dependencies or build-related artifacts, modules etc.

Now compile, test run on bloop server

Coursier sbt plugin

# Edit or create ${PROJECT_ROOT}/project/project/plugins.sbt
// Setup:
// also see project/plugins.sbt
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC3-1")

# Edit or create ${PROJECT_ROOT}/project/plugins.sbt
// Setup:
// also see project/project/plugins.sbt
classpathTypes += "maven-plugin"
coursierUseSbtCredentials := true

Checksum problems

When using the 1.x version of the coursier sbt plugin I ran into some problems with a 3rd party artifact checksum not being correct. Following the comments on coursier ticket 319 I added the following but haven’t needed it since in other projects:

coursierChecksums := Nil
coursierArtifactsChecksums := Nil