Effective Scala, part 6 - Scala Build Tool (SBT)

Scala

src/project dir contains configuration about SBT - build.properties to specify sbt version, plugins.sbt to specify sbt plugins, and so on.

src/build.sbt contains the configuration to build the project itself.

̄An sbt build (build.sbt) is composed of - settings and tasks. A setting parametrises the build, and consists of a key value pair. A task may also by parametrised by settings.

Configurations in build.sbt§

  • Compile (default configuration where sbt looks first)
  • Test
  • Zero (no specified config, where fallback values live)

Scoping a Setting§

Different values can be applied to a single setting by scoped its key.

A key can be scoped along any of the 3 axes:

  • Configuration. e.g., Compile / sourceDirectory, Test / sourceDirectory
  • Task. e.g., includeFilter, unmanagedSources / includeFilter where the latter includeFilter is scoped by unmanagedSources task.
  • Sub-project. e.g., mainProject / scalaVersion, subProject / scalaVersion

Axes can be combined too: subProject / Compile / unmanagedSources / includeFilter. I think the order is: project / configuration / task / key.