Chapter 3. Core concepts

 

This chapter covers

  • Configuring settings, tasks, and projects
  • Reusing values across settings
  • Learning the core concepts of an sbt build
  • Adding additional projects to the preowned-kittens build

In chapter 2, you set up an initial sbt project and used the command line to perform basic operations. This chapter focuses on taking this build beyond the out-of-the-box defaults and into something that you can call your own. As you go, you’ll learn the core of sbt, the fundamental concepts that pervade any build. These are the components you can use to construct any build you want, and indeed they’re the mechanism by which sbt provides a default build. After reading this chapter, given sufficient time, you could implement sbt’s default build, although we don’t recommend that you do so!

3.1. Creating builds

As you may recall from chapter 2, the preowned-kittens build defines two files:

  • project/build.properties— This file defines the sbt version.
  • build.sbt— This file defines the actual build.

Let’s look at the build.properties file you defined:

sbt.version=0.13.5

Although this file can be used to specify several things, it’s commonly used only to specify the sbt version. For the preowned-kittens build, we’re using sbt 0.13, the latest release of sbt. More important is the build.sbt file.

The core of the preowned-kittens build is its build.sbt file. Here’s what you ended up with at the end of the last chapter:

3.2. Defining settings

3.3. Creating and executing tasks

3.4. Using configurations

3.5. Defining with subprojects

3.6. Putting it all together

3.7. Summary