concept sbt in category scalatra

appears as: sbt
Scalatra in Action

This is an excerpt from Manning's book Scalatra in Action.

Let’s run your newly generated Scalatra project using sbt. To do so, cd into the top-level my-scalatra-web-app project by typing cd my-scalatra-web-app. Then type either ./sbt (Linux or Mac) or sbt (Windows) at the command prompt to start sbt. The first time you do this, you may as well go get a cup of coffee; sbt will download an entire Scala development environment, including the language, a compiler, and the Scala standard libraries, and then grab all the dependencies needed to run a Scalatra application. This can take a while, depending on the speed of your internet connection. At the end, you’ll see the > character, which is the sbt command prompt, as shown in figure A.5.

sbt (Simple Build Tool) is a build tool for Scala. It can be used to build a Scalatra application, and you should already be familiar with it, having used it in the previous chapter. This section will look at some of the details of developing a Scalatra application with sbt.

When you’re using the giter8 (g8) template, a Scalatra application is built around an sbt project. This means there’s an sbt build definition, and the project layout follows the standard sbt structure and conventions. As a result, you can let sbt manage the dependencies and use it to build the application, and reuse the wealth of functionality wrapped in sbt extensions.

Let’s take a closer look at the settings. A Setting maps a key to some value. Using sbt’s := operator, you can construct a setting that, when evaluated, sets a value in the project’s internal map. For example, the following code represents an assignment to the keys organization and name, describing the publisher of the project and the project’s name, respectively:

organization := "org.scalatra"
name := "chapter09"

sbt has built-in keys that are imported from sbt.Keys._. Plugins often define their own keys, which can be imported as well.