sbt uses a key-value model where settings are evaluated once at project load time and tasks are evaluated on demand. This page documents the core settings and tasks available in sbt.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sbt/sbt/llms.txt
Use this file to discover all available pages before exploring further.
Key Types
sbt defines three main types of keys:| Key Type | Description | Evaluation |
|---|---|---|
SettingKey[T] | Values computed once at project load | Once per session |
TaskKey[T] | Executable tasks that may have side effects | On demand |
InputKey[T] | Tasks that accept command-line input | On demand with args |
Core Build Settings
Project Identity
Project name used for artifact publication and display.
Organization or group ID for the project.
Project version for artifact publication. Default:
"0.1.0-SNAPSHOT"Scala Configuration
The version of Scala used for building. This is one of the most important settings.
The Scala version substring describing binary compatibility (e.g., “2.13”, “3”).
Automatically derived from
scalaVersion.The versions of Scala used when cross-building.
Organization/group ID of the Scala used in the project. Advanced setting for Scala language clones. Default:
"org.scala-lang"Path Settings
The base directory for the build, project, configuration, or task depending on scope.
Main directory for files generated by the build.
Default directory containing sources.Default:
baseDirectory.value / "src"Default Scala source directory.Default:
sourceDirectory.value / "scala"Default Java source directory.Default:
sourceDirectory.value / "java"Default unmanaged resource directory for user-defined resources.Default:
sourceDirectory.value / "resources"Directory for compiled classes and copied resources.Default:
target.value / "classes"Core Tasks
Compilation Tasks
Compiles sources and returns compilation analysis.
Deletes files produced by the build, such as generated sources, compiled classes, and task caches.
Interactive Tasks
Starts the Scala interpreter (REPL) with the project classes on the classpath.
Starts the Scala interpreter with the project dependencies on the classpath (without project classes).
Run Tasks
Runs a main class, passing along arguments provided on the command line.
Runs the main class selected by the first argument, passing the remaining arguments to the main method.
Test Tasks
Executes the tests that either failed before, were not run, or whose transitive dependencies changed.
Executes the tests provided as arguments or all tests if no arguments are provided.
Executes tests that failed in previous runs or whose dependencies changed.
Package Tasks
Produces the main artifact, such as a binary JAR. Typically an alias for
packageBin.Produces a main artifact, such as a binary JAR.
Produces a source artifact containing sources and resources.
Produces a documentation artifact containing API documentation.
Documentation Tasks
Generates API documentation using Scaladoc.
Compiler Settings
Options for the Scala compiler.
Options for the Java compiler.
The maximum number of errors, such as compile errors, to list.
Dependency Management Settings
Declares managed dependencies.
Defines additional resolvers for retrieving dependencies.
Runtime Settings
If true, forks a new JVM when running. If false, runs in the same JVM as the build.
Options passed to a new JVM when forking.
Selects the Java installation used for compiling and forking. If None, uses the Java installation running the build.
Common Patterns
Scoping Keys
Keys can be scoped to different contexts:Modifying Settings
Use
.value to reference the value of another setting or task within a setting/task definition.Task Dependencies
Tasks automatically track their dependencies:See Also
- Configurations - Understanding Compile, Test, and other configurations
- Directory Structure - Standard sbt project layout
- Command Line - Running sbt commands and options