In this section, we provide a brief overview of build tools for Scala. In general, build tools support the build process in several ways:
When using the Java or Scala command-line tools, the developer is responsible for setting the dreaded classpath. This can quickly become unwieldy when dependencies even as simple as JUnit are involved, so this is not something you would usually want to do manually.
1 2 3 4 5 | <dependency>
<groupId>org.restlet</groupId>
<artifactId>org.restlet.ext.spring</artifactId>
<version>${restlet.version}</version>
</dependency>
|
1 | <dependency org="junit" name="junit" rev="4.11"/>
|
In the simplest case, sbt does not require any configuration and will use reasonable defaults. The project layout is similar to that used by Maven:
sbt supports two configuration styles, one based on a simple Scala-based domain-specific language, and one based on the full Scala language for configuring all aspects of a project.
A minimal sbt build.sbt file would look like this. The empty lines are required, and the file must be placed in the project root folder.
1 2 3 | name := "integration-scala"
version := "0.0.2"
|
Additional dependencies can be specified either one at a time
1 | libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"
|
or as a group
1 2 3 4 | libraryDependencies ++= Seq(
"org.scala-lang" % "scala-actors" % "2.10.1",
"com.novocode" % "junit-interface" % "0.10" % "test"
)
|
Examples of more complex Scala-based project configurations can be found in these examples:
sbt includes a growing plugin ecosystem. Key examples include
The IntelliJ IDEA Scala plugin also integrates directly with sbt.