Simple Build Tool
Encyclopedia
Simple Build Tool is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 build tool for Scala projects written by Mark Harrah that aims to do the basics well.

Its main features are:
  • SBT knows how to compile Scala code, to run tests, to package jars and wars, and to start the Scala interpreter with the right classpath.
  • Build recipes are specified using a Scala DSL, in a mix of declarative and imperative styles.
  • SBT manages dependencies, leveraging existing Maven
    Apache Maven
    Maven is a build automation and software comprehension tool. While primarily used for Java programming, it can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. Maven serves a similar purpose to the Apache Ant tool, but it is based on different concepts and...

     or Ivy
    Apache Ivy
    Apache Ivy is a transitive relation dependency manager. It is a sub-project of the Apache Ant project, with which Ivy works to resolve project dependencies. An external XML file defines project dependencies and lists the resources necessary to build a project...

     packages repositories.
  • SBT can run continuous compilation, testing and deployment, helping programmers adhere to the TDD methodology.
  • Projects layout is very similar to the one recommended for Maven, making it easy to switch from Maven to SBT and back, if needed.
  • Changes to source files are monitored and a compiler plugin used to gather dependency information so only a minimum set of dependent sources will be recompiled, reducing rebuild times.
  • Mixed Scala/Java projects are supported.

Example

A SBT project can be configured using either a "light" configuration or a "full" configuration. Light configuration files consist of multiple Scala expressions in a .sbt file. Full configuration files are complete Scala programs that use SBT as a library. Below is an example of light configuration:


// Set the project name to the string 'My Project'
name := "My Project"

// The := method used in Name and Version is one of two fundamental methods.
// The other method is <<=
// All other initialization methods are implemented in terms of these.
version := "1.0"

// Add a single dependency
libraryDependencies += "junit" % "junit" % "4.8" % "test"

// Add multiple dependencies
libraryDependencies ++= Seq(
"net.databinder" %% "dispatch-google" % "0.7.8",
"net.databinder" %% "dispatch-meetup" % "0.7.8"
)

// Exclude backup files by default. This uses ~=, which accepts a function of
// type T => T (here T = FileFilter) that is applied to the existing value.
// A similar idea is overriding a member and applying a function to the super value:
// override lazy val defaultExcludes = f(super.defaultExcludes)
//
defaultExcludes ~= (filter => filter || "*~")
/* Some equivalent ways of writing this:
defaultExcludes ~= (_ || "*~")
defaultExcludes ~= ( (_: FileFilter) || "*~")
defaultExcludes ~= ( (filter: FileFilter) => filter || "*~")

// Use the project version to determine the repository to publish to.
publishTo <<= version { (v: String) =>
if(v endsWith "-SNAPSHOT")
Some(ScalaToolsSnapshots)
else
Some(ScalaToolsReleases)
}

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK