Small information nuggets and recipies about sbt
✂️ sbt
Table of Contents
- Cross compile and publish local library
- Download SBT sources
- Run console with test libraries loaded
- Run sbt in debug mode
- Using sbt offline, to avoid dependency resolution failure
- Run tests with coverage
- Visualize library dependencies
- Publish library changes locally
- Run command via proxy
- Run command opening a port to debug
- Run command continually
- Run only the tests that have failed
- Run only a single test
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
… ~/.sbt/0.13/plugins/plugins.sbt
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"