Lesson 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. But programs are usually composed of several parts: they depend on other projects and libraries, and they are organized 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, build and execute 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. In this book, as well as the majority of Scala projects, you are going to use the default SBT configuration. In this book, you are not going to learn any of its advanced uses or functionalities of SBT as this goes beyond its scope. If you’d like to learn more about SBT, have a look at its documentation at www.scala-sbt.org.