sbt in Action
The simple Scala build tool
Joshua Suereth and Matthew Farwell
  • November 2015
  • ISBN 9781617291272
  • 280 pages
  • printed in black & white

Covers core concepts using the Scala build tool. A useful read for beginners and advanced users alike.

Iain Campbell, Tango Telecom

A tutorial about effectively building Scala projects, sbt in Action 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. Finally, it covers how to deploy software effectively. You'll learn to appreciate how sbt improves the process of developing software, not just running builds.

Table of Contents detailed table of contents



about this book

author online

about the authors

about the cover illustration

Part 1 Why sbt?

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

sbt is a build tool native to Scala that can transform any build scenario into a streamlined, automated, and repeatable process. Its interactive shell lets you customize your builds on the fly, and with sbt?s unique incremental compilation feature, you can update only the parts of your project that change, without having to rebuild everything. Mastering sbt, along with the right patterns and best practices, is guaranteed to save you time and trouble on every project.

About the book

sbt in Action, first and foremost, teaches you how to build Scala projects effectively. 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. Along the way, you?ll work through real projects that demonstrate how to build and deploy your projects regardless of development methodology or process.

What's inside

  • Master sbt's loosely coupled libraries
  • Effectively manage dependencies
  • Automate and simplify your builds
  • Customize builds and tasks

About the reader

Readers should be comfortable reading 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. Matthew Farwell is a senior developer and the author of the Scalastyle style checker.

combo $44.99 pBook + eBook + liveBook
eBook $35.99 pdf + ePub + kindle + liveBook

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks