sbt tips

Brad Fritz

July 7th, 2014

Manual Install

Most OSes have packages now, but if you must…

curl -O

echo 'SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"' > sbt
echo 'java $SBT_OPTS -jar `dirname $0`/sbt-launch.jar "$@"' >> sbt

chmod u+x sbt

Multiple Tasks from Command Line

Specify each task’s “phrase” as an argument:

sbt "task1" "my task 2" ...


sbt "project core" "dependency-graph"
sbt "project dsl" "clean" "~ compile"

Dependency Graph
(in simple project)

Add to project/plugins.sbt:

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

Add to build.sbt:



sbt dependency-graph

Output is similar to mvn dependency:tree .

Dependency Graph Output

Global Settings and Plugins

Global Settings and Plugins (cont.)

Let’s enable the dependency-graph task globally…


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


Seq(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*)

Plugin Caveat

sbt 0.13.5 (latest release and preview of 1.0) introduces auto plugins.

Pull Artifacts from Local Maven Repo

$ du -sh ~/.m2/repository ~/.ivy2/cache/
3.1G   /home/brad/.m2/repository
1.5G   /home/brad/.ivy2/cache/

Tell sbt to check your local Maven repo for artifacts with:

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

or in recent versions of sbt:

resolvers += Resolver.mavenLocal