Although you can use Ant and Maven to build your Scala projects, SBT, or the Simple Build Tool, is the de facto build tool for Scala applications. SBT makes the basic build and dependency management tasks simple, and lets you use the Scala language itself to conquer more difficult tasks.

SBT uses the same directory structure as Maven, and like Maven, it uses a “convention over configuration” approach that makes the build process incredibly easy for basic projects. Because it provides a well-known, standard build process, if you work on one Scala project that’s built with SBT, it’s easy to move to another project that also uses SBT. The project’s directory structure will be the same, and you’ll know that you should look at the build.sbt file and the optional project/*.scala files to see how the build process is configured.

Like Maven, under the covers, SBT’s dependency management system is handled by Apache Ivy. This means that all those Java projects that have been created and packaged for use with Maven over the years can easily be used by SBT. Additionally, other JAR files not in an Ivy/Maven repository can simply be placed in your project’s lib folder, and SBT will automatically find them.

As a result of all these features, with very little effort on your part, SBT lets you build projects that contain both Scala and Java code, unit tests, and both managed and unmanaged dependencies.


All examples in this chapter were tested with SBT version 0.12.3.

Get Scala Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.