SBT: build.sbt, Dependencies & the Shell
SBT is the most widely-used build tool for Scala projects -- handling compilation, dependency management, testing, and packaging, roughly analogous to Maven or Gradle for Java. Notably, build.sbt is written in actual Scala syntax, not a separate configuration language.
build.sbt & Dependencies
name := "my-app"
version := "1.0"
scalaVersion := "2.13.10"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % Test
// %% appends the project's Scala BINARY VERSION automatically
// (resolves to scalatest_2.13) -- since Scala libraries are often
// published as separate artifacts per Scala version
// % Test scopes this dependency to testing only -- not bundled
// into the actual shipped production artifactThe Interactive Shell
sbt
# Enters an interactive session -- run multiple commands without
# restarting the JVM for each one, avoiding real per-command startup cost
> compile
> test
> run
# Watch mode: automatically re-runs a command when source files change
> ~testPinning the SBT Version Itself
# project/build.properties
sbt.version=1.9.6
# Ensures every developer and CI use the same SBT version,
# regardless of what's installed globally on a given machineIncremental Compilation
Rather than recompiling an entire large codebase after every small change, SBT analyzes exactly which files changed (and what depends on them) and recompiles only that genuinely-affected subset -- meaningfully faster iterative development on larger projects.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free