3    SBT – Scala Build Tool

After reading this lesson, you’ll be able to:

  • Run commands in SBT
  • Create an SBT project
  • Describe the structure of the files of a Scala project built with SBT

In the previous lesson, you have learned how to evaluate snippets of code using the Scala REPL. Programs have several components: they depend on other modules and libraries, and they are structured in multiple files and folders. In this lesson, you’ll discover the basics of the Scala Build Tool – or “SBT”. You’ll compile and run your first Scala program on the JVM using SBT. In this book, you’ll use SBT to manage dependencies, compile your code, and run your Scala programs.

3.1           Why SBT?

You can build Scala projects using several build tools such as Maven, Ant, and Gradle, but SBT is the most common build tool in the community. SBT is a convoluted but powerful tool that manages your dependencies, and it defines the build cycle of your code. SBT has its syntax and predefined instructions. You can also use SBT plugins, which are programs written using the SBT syntax, to add new commands or to modify existing behaviors of your build process. Throughout this book, you are going to write Scala programs that use the default SBT configuration. You are not going to learn about the SBT advance uses and functionalities in this book, but you can have a look at its documentation at www.scala-sbt.org if you'd like to learn more about it.

3.2           SBT Installation

3.3           SBT Commands

3.4           Your first SBT Project

3.5           SBT Project Structure

3.6           Summary