Book Image

Getting Started with SBT for Scala

By : Shiti Saxena
Book Image

Getting Started with SBT for Scala

By: Shiti Saxena

Overview of this book

<p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>
Table of Contents (13 chapters)

Preface

Simple Build Tool, abbreviated to SBT, is a build tool for Scala and Java projects. SBT simplifies the process of developing, building, and maintaining a project. This book will show you how to build a Scala project using SBT Version 0.12.3, and the different ways in which SBT can be set up.

What this book covers

Chapter 1, Hello World with SBT, introduces SBT, and how to get it up and running with an example.

Chapter 2, .sbt Build Definitions, explains the components of a simple .sbt build file.

Chapter 3, Dependency Management, explains how project dependencies can be configured in SBT.

Chapter 4, Full Build Definitions, introduces the .scala build definition and the scenarios in which it can be extremely useful.

Chapter 5, Compile, Test, and Run, explains SBT commands and some configurations which can come in handy when developing an application.

What you need for this book

All that you need to use this book is a PC with Linux or Windows OS or a Mac, a text editor, and Java 1.6 or later. There are SBT plugins available for various IDEs, but setting it up is completely optional.

Who this book is for

This book is aimed at developers who want to use SBT to build Scala projects. The readers are expected to know programming in Scala.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning:

Code words in text are shown as follows: "Create an sbt.bat file."

A block of code is set as follows:

class IntroSpec extends Specification{ 
  "The phrase 'Never odd or even'" should{ 
    "be a palindrome" in { 
      Introduction.isPalindrome("Never odd or even") must beTrue 
    } 
  } 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

class IntroSpec extends Specification{ 
  "The phrase 'Never odd or even'" should{ 
    "be a palindrome" in { 
      Introduction.isPalindrome("Never odd or even") must beTrue 
    } 
  } 

Any command-line input or output is written as follows:

>compile
[success] Total time: 0 s, completed

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "Clicking on the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.