Book Image

Getting Started with SBT for Scala

By : Shiti Saxena
Book Image

Getting Started with SBT for Scala

By: Shiti Saxena

Overview of this book

<p>Build tools are a boon to developers working on large projects. With the configuration to run/execute the project moved out, developers can focus more on the project. SBT is a build tool designed for Scala and Java projects. It provides developers with a high productivity work environment hence it comes in really handy when dealing with large projects.</p> <p>Getting Started with SBT for Scala gets you going with using SBT and also introduces its advanced concepts. SBT is a build tool that uses a Scala-based DSL. Additionally, SBT has some interesting features that come in handy during development, such as starting a Scala REPL with project classes and dependencies on the classpath, continuous compilation and testing with triggered execution, and much more.</p> <p>Getting Started with SBT for Scala introduces SBT and its various features. It shows how to set up the build definition for a Scala project using sample code to explain different scenarios and use cases. It explains the basic configuration required to compile, test, and run a project using SBT. We will take a look at the additional configuration and settings that can be set to suit the project requirements. You will also learn how to handle project dependencies in SBT and use Scala files to define the build. It shows how to fork the JVM in SBT for different processes and specific configurations. It also explains the intricacies of the build definition, parallel execution.</p> <p>This book will make you familiar with SBT so that you can use it for different kinds of projects like simple, and multiple modules which can be dependent or independent.</p>
Table of Contents (13 chapters)

Commands


What is a command? Every statement executed from the SBT prompt is a command. A command can either be an SBT task or command.

In SBT, each task represents a specific operation. Most of the tasks are run from the SBT prompt as commands while some are used internally by SBT. Based on the impact, tasks can be split into:

  • Project-level tasks

  • Configuration-level tasks

Tasks such as clean, update, publish, and so on, are categorized as project-level tasks, while tasks such as compile, console, run, test, run-main, and so on, fall into the category of configuration-level tasks, as they can be executed for different configurations.

In SBT, a command is just another type like keys. A command has access to the current state of the build and can modify that state. So, commands are very much like task keys with additional privileges. Some of the commonly used commands are as follows:

  • exit or quit: These are used to end an interactive session or build. You could also use Ctrl + D on Unix-based systems...