✂️ sbt

Small information nuggets and recipies about sbt

  • commandName == command-name

(most recent on top)

Cross compile and publish local library

sbt ^publishLocal

Download SBT sources

sbt updateClassifiers         // download sources and docs for all libs
sbt updateSbtClassifiers      // downloads sources and docs for sbt

Run console with test libraries loaded

run test:console

Run sbt in debug mode

sbt --debug

Using sbt offline, to avoid dependency resolution failure

set offline := true

Run tests with coverage

… there is also a separate “Run with Coverage” button in IntelliJ IDEA

sbt coverage test

Visualize library dependencies


addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.1")

… commands

sbt dependencyTree
sbt dependencyBrowseGraph
sbt "whatDependsOn com.example library-name 0.0.0"

Publish library changes locally

sbt publishLocal

Run command via proxy

sbt -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 "~run 9000"

Run command opening a port to debug

… from the command line

sbt -jvm-debug 5005 "~run 9400"

… form IntelliJ IDEA (Run/Debug Configuration)

  • Edit Configurations… ➤ Remote ➤ Port = 5005

Run command continually

… put a tilde in front of it

sbt ~compile
sbt ~test
sbt ~testQuick

Run only the tests that have failed

sbt testQuick

Run only a single test

sbt 'testOnly *TestSpec -- -z "name of the spec"'
sbt "testOnly name.spaced.TestSpec -- pattern"
sbt "it:testOnly name.spaced.TestSpec -- pattern"