SBT in Action
The simple Scala build tool
Joshua Suereth and Matthew Farwell
  • MEAP began April 2013
  • Publication in October 2015 (estimated)
  • ISBN 9781617291272
  • 325 pages (estimated)
  • printed in black & white

SBT in Action is first and foremost a tutorial about effectively building Scala projects. It introduces the sbt tool with a simple project that establishes the fundamentals of running commands and tasks. Next, it shows you how to use the peripheral libraries in sbt to make common tasks simpler. This includes an I/O library to deal with files and how to parse user input in a meaningful fashion. Finally, it covers how to deploy software effectively.

Most importantly, you'll learn to appreciate how sbt improves the process of developing software, not just running builds.

Table of Contents show full


1. Why sbt?

1.1. Why a build tool?

1.2. Apache Ant

1.3. Apache Maven

1.3.1. Build definition

1.3.2. Maven workflow-default lifecycle

1.3.3. Adding another task to a Maven build

1.3.4. Advantages of Maven

1.3.5. Limitations of Maven

1.4. Gradle

1.4.1. What is Gradle?

1.4.2. Gradle workflow

1.4.3. Adding another task to a Gradle build

1.4.4. Advantages of Gradle

1.4.5. Limitations of Gradle

1.5. Why sbt?

1.5.1. How sbt works

1.5.2. Plugin architecture vs. tasks

1.5.3. Phases versus task dependencies

1.5.4. Passing information around your build

1.5.5. Working with Scala

1.5.6. Multiproject builds

1.5.7. Dependency resolution

1.6. Interactivity/reactivity of sbt

1.6.1. Quicker compilation and testing cycle

1.6.2. Quicker compilation and testing cycle

1.6.3. sbt and the Scala REPL-the console command

1.7. Summary

2. Getting started

2.1. Setting up sbt

2.1.1. Setting the PATH in bash (for Linux/Mac)

2.1.2. Running sbt

2.2. Setting up a build

2.2.1. Tasks

2.2.2. Settings

2.3. Running code

2.4. Testing code

2.4.1. Running tasks when sources change

2.4.2. Selecting tests with interactive tasks

2.5. Summary


3. Core Concepts

3.1. Creating builds

3.2. Defining settings

3.2.1. Initializations

3.3. Creating and executing tasks

3.3.1. Task dependencies

3.4. Using configurations

3.5. Defining with subprojects

3.6. Putting it all together

3.7. Summary

4. The default build

4.1. Compiling your code

4.2. Finding your sources

4.2.1. Standard organization of sources

4.2.2. Testing sources

4.2.3. Custom organization of sources

4.2.4. Filtering the source you want

4.3. Depending on libraries

4.3.1. Unmanaged dependencies

4.3.2. Managed dependencies

4.3.3. Managed dependencies and configurations

4.4. Packaging your project

4.4.1. Identifying your project

4.5. Summary


5. Testing

5.1. Configuring Specs2 with sbt

5.1.1. Reports and forking tests

5.1.2. Digging deeper: other options for forking

5.2. JUnit and using custom code

5.2.1. Report generation with JUnit

5.3. ScalaCheck

5.4. Integration testing

5.4.1. ScalaTest and Selenium

5.4.2. Challenges of integration testing

5.4.3. Adding integration tests to sbt

5.5. Summary

6. The IO and Process Libraries

6.1. Packaging using processes

6.2. Packaging using the sbt.IO library

6.3. More mappings

6.4. Task dependencies

6.5. Logging using the sbt logger

6.6. Running your build using fork

6.7. Linking everything together: dependencies

6.8. Linking everything together: processes

6.9. Summary

7. Accepting user input

7.1. Accepting user input with input tasks

7.2. Defining an interface with parsers

7.3. Defining a database evolution parser

7.4. Helping the user with autocomplete

7.5. Summary

8. Using Plugins and External Libraries

8.1. Using plugins to check your code

8.2. Using the Revolver plugin to restart the application

8.3. Creating your uber jar using the assembly plugin

8.4. Including a library in your plugin build

8.5. Adding a plugin for use in all of your projects-signing your projects

8.6. Adding local credentials for deployment

8.7. Summary

9. Debugging Your Build

9.1. Running sbt

9.2. Making your build compile

9.3. Ensuring tasks are run

9.4. Resolving dependency conflicts

9.4.1. Fixing resolution failures

9.4.2. Fixing resolution conflicts

9.5. Summary


10. Automating workflows with commands

10.1. Creating a simple command

10.2. Running tasks in parallel

10.3. Parsing input with commands

10.4. Creating useful help messages

10.5. Summary

11. Defining Plugins

11.1. Reusing code using Scala files

11.2. Introducing the AutoPlugin interface

11.2.1. Taking a closer look-the plugin definition

11.2.2. Taking a closer look-task and setting dependencies

11.3. Testing a plugin with the scripted plugin

11.4. Using configurations in your plugin

11.5. Adding incremental tasks

11.5.1. Adding incremental tasks with .previous-a sneak preview of 1.0

11.6. Making things easy for the user-more about the AutoPlugin interface

11.7. Summary


12. Distributing Your Projects

12.1. Publishing a library

12.2. Publishing locally

12.3. Publishing a simple server

12.4. Generating a distribution

12.5. Creating a Linux distribution

12.6. Summary


Appendix A: What you need to know about Ivy

A.1. Modules

A.2. Module identification

A.3. Artifacts

A.4. Differences in Ivy and Maven

A.5. Configuration

A.6. Resolvers

A.7. Resolving dependency conflicts

Appendix B: Migrating to Autoplugins

B.1. Older sbt plugins

B.2. Migrating to autoplugins

Appendix C: Advanced setting/task API

C.1. Optional settings

C.2. Failing tasks

C.3. Dynamic tasks

C.4. Composing InputTasks

About the Technology

Simple Build Tool: sbt. The idea of a high quality build tool for Scala is indeed simple, but sbt itself is richly-featured and powerful. Documentation for sbt is sparse, and the blogs, tutorials, and other bits scattered across the web leave you wanting a comprehensive, accurate picture of how to build Scala projects effectively and efficiently. This book will help you transform ugly, complex builds into a streamlined, automated, and repeatable process.

What's inside

  • Master sbt's loosely coupled libraries
  • Effectively manage dependencies in your builds
  • Automate and simplify your builds
  • Practical deployment techniques
  • Customize builds and tasks for your own use cases

About the reader

This book assumes you're comfortable reading and writing Scala code. No experience with sbt required.

About the authors

Josh Suereth is a Senior Software Engineer at Typesafe and the author of Scala in Depth. He is the author of several open source Scala projects, including the Scala automated resource management library, the PGP sbt plugin. Matthew Farwell is a Senior Software developer at Nexthink. He is the author of Scalastyle, the style checker for Scala and is a contributor to JUnit and the Eclipse Scala IDE.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $44.99 pBook + eBook
MEAP eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks