Getting Started with SBT for Scala

Book description

This practical guide to SBT will make your next large-scale Scala or Java project a lot more speedy and manageable. Familiarize yourself quickly and easily with the features and configuration of this powerful build tool.

  • Establish simple and complex projects quickly
  • Employ Scala code to define the build
  • Write build definitions that are easy to update and maintain
  • Customize and configure SBT for your project, without changing your project’s existing structure

In Detail

Build tools are a boon to developers working on large projects. With the configuration to run/execute the project moved out, developers can focus more on the project. SBT is a build tool designed for Scala and Java projects. It provides developers with a high productivity work environment hence it comes in really handy when dealing with large projects.

Getting Started with SBT for Scala gets you going with using SBT and also introduces its advanced concepts. SBT is a build tool that uses a Scala-based DSL. Additionally, SBT has some interesting features that come in handy during development, such as starting a Scala REPL with project classes and dependencies on the classpath, continuous compilation and testing with triggered execution, and much more.

Getting Started with SBT for Scala introduces SBT and its various features. It shows how to set up the build definition for a Scala project using sample code to explain different scenarios and use cases. It explains the basic configuration required to compile, test, and run a project using SBT. We will take a look at the additional configuration and settings that can be set to suit the project requirements. You will also learn how to handle project dependencies in SBT and use Scala files to define the build. It shows how to fork the JVM in SBT for different processes and specific configurations. It also explains the intricacies of the build definition, parallel execution.

This book will make you familiar with SBT so that you can use it for different kinds of projects like simple, and multiple modules which can be dependent or independent.

Table of contents

  1. Getting Started with SBT for Scala
    1. Table of Contents
    2. Getting Started with SBT for Scala
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Hello World with SBT
      1. Why SBT?
      2. Installing SBT
        1. Installing from a package
          1. Installing on Mac
        2. Installing SBT manually
      3. Creating a new project
      4. Compiling, testing, and running your project
      5. Going interactive with the SBT shell
        1. Triggering SBT commands on saves
      6. Summary
    10. 2. .sbt Build Definitions
      1. The theory of .sbt
      2. The .sbt syntax
      3. Understanding keys
        1. Keys
          1. Setting keys
            1. Path-related setting keys
          2. Task keys
          3. Input keys
      4. Working with scopes
      5. Summary
    11. 3. Dependency Management
      1. Quick introduction to Maven or Ivy dependency management
        1. How Ivy works
          1. Resolve
          2. Retrieve
          3. Publish
      2. Dependency management in SBT
        1. Automatic dependency management
          1. Declaring dependencies in the build definition
            1. A URL for the dependency JAR
            2. Extra attributes
            3. Classifiers
            4. Transitivity
            5. Download documentation
          2. Dependencies using Maven files
          3. Dependencies using Ivy files or Ivy XML
          4. Adding JAR files manually
      3. Resolvers
      4. Summary
    12. 4. Full Build Definitions
      1. Build definition project
      2. .sbt and .scala
      3. Working with full build definitions
      4. Multiproject builds
      5. Summary
    13. 5. Compile, Test, and Run
      1. Commands
      2. Logging
      3. Forking the JVM
      4. Parallel execution
      5. SBT scripts and REPL
      6. Classpath, sources, and resources
      7. Test
      8. Summary
    14. Index

Product information

  • Title: Getting Started with SBT for Scala
  • Author(s):
  • Release date: September 2013
  • Publisher(s): Packt Publishing
  • ISBN: 9781783282678