Chapter 4. The default build

 

This chapter covers

  • Arranging source files
  • Dealing with dependencies (libraries)
  • Compiling Scala and Java code
  • Running individual tests
  • Packaging your code

In the previous chapter, you learned the nuts and bolts: tasks, settings, projects, and builds. This chapter covers the structure of the building: the default build. Unlike the previous chapters, you won’t add much to the preowned-kittens project, but instead you’ll investigate how the existing build works so you know where to add new features.

We’ll deconstruct the build from the general tasks you need to accomplish, back to the pieces that make it up. Let’s walk back through the tasks you ran in chapter 2 and see what sbt does to execute them. We’ll walk through the tasks compile, run, test, package, and then publish.

4.1. Compiling your code

One of the primary purposes of a build tool is to compile code. But in order to compile code, sbt first needs to know a few things. You can ask sbt what it needs using the inspect tree command on the sbt prompt. First go back to the kittens folder you created earlier for your projects. Then start sbt in this directory. When the prompt appears, type inspect tree compile:compile:

4.2. Finding your sources

4.3. Depending on libraries

4.4. Packaging your project

4.5. Summary

sitemap