Chapter 9. Debugging your build
This chapter covers
- Figuring out why your build won’t compile
- Ensuring tasks will run when desired
- Correctly resolving dependencies
In this chapter we’re going to look at a set of common failures in sbt and how to debug the underlying causes. The goal of this chapter is to learn how to debug sbt by understanding the initialization, loading, and execution of your build. Throughout the chapter, we’ll dive a bit deeper into the core aspects of sbt, and you’ll see the same concepts from chapter 3 in a new light.
Debugging in sbt takes on different aspects, depending on where in the lifecycle the failure is occurring, which correlates to the lifecycle of an sbt build. Let’s take a look at a loose sketch of what sbt does when it loads your build file:
- Resolve sbt and any required plugins.
- Compile your build definition.
- Execute any requested tasks or commands.
Each of these phases pushes out different error messages. Because sbt uses a statically typed build definition language, you can catch a lot of errors in stages 1 and 2. But some errors still happen when attempting to run tasks. Let’s split these into three classes of errors:
- An error in the task definition
- Dependency resolution issues
- Task wiring issues