SBT (software)

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

SBT (Scala Build Tool)
Sbt-logo
Developer(s) Mark Harrah
Stable release 0.13.9[1] / August 12, 2015 (2015-08-12) [2]
Preview release 0.13.8-RC1 / March 10, 2015 (2015-03-10) [3]
Development status Active
Written in Scala
Operating system Cross-platform
Platform Java
Type Build automation
License BSD License
Website www.scala-sbt.org

SBT is an open source build tool for Scala and Java projects, similar to Java's Maven or Ant.

Its main features are:

  • native support for compiling Scala code and integrating with many Scala test frameworks
  • build descriptions written in Scala using a DSL
  • dependency management using Ivy (which supports Maven-format repositories)
  • continuous compilation, testing, and deployment
  • integration with the Scala interpreter for rapid iteration and debugging
  • support for mixed Java/Scala projects

SBT is the de facto build tool for the Scala community,[4] used by the Lift web framework[5] and Play Framework.

Typesafe Inc., Scala's commercial outlet, has called SBT "arguably the best tool for building Scala projects," with the two most prominent key features being incremental compilation and an interactive shell.[6] When continuous compilation mode is entered, the Scala compiler is only once instantiated which eliminates subsequent startup costs, and source file changes are tracked so that only affected dependencies are recompiled. The interactive console allows modifying build settings on the fly and entering the Scala REPL along with all class files of the project.[7] The popularity of the incremental compilation has prompted Typesafe to extract this feature in the form of an independent component called Zinc.[6]

SBT had already fed back into the Scala standard library before, when its process API was adopted in Scala 2.9.[8]

Build files

An 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.[9] Below is an example of light configuration:

// Set the project name to the string "my-project" and the version to 1.0.0.
name := "my-project"

version := "1.0.0"

// Add a single dependency, for tests.
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"	
)

// Use the project version to determine the repository to publish to.
publishTo := Some(if (version.value endsWith "-SNAPSHOT") "http://example.com/maven/snapshots" else "http://example.com/maven/releases")

Example use

SBT may be invoked for each build command, or it may enter interactive mode if no command is given. To clean build products of the current build:

$ sbt clean

Multiple commands may be used on the same line. To run a single test named "Foo" and then publish exported jars:

$ sbt "testOnly Foo" publish

Extensibility and integration

The functionality of SBT can be extended through a plugin architecture.[10] A dedicated website was set up for community contributed plugins, which cover various areas such as signing, packaging, publishing and releasing artifacts, connecting to other services such as blogs and databases, or integrating with other technologies such as deploying to the Android platform.[11]

There are plugins to automatically create project files for the Eclipse and IntelliJ IDEA IDEs. On the other hand, an IntelliJ IDEA plugin allows the SBT console to be integrated into IDEA, and projects can choose to use SBT for building.

Comparison and criticism

As with most software tools, SBT has found advocates and critics. It is often compared against Maven, which is a standard build tool in the Java world. In particular, the domain specific language used for SBT build files has attracted criticism as being cryptic compared to the pure declarative approach of Maven's XML files. Furthermore, an incompatible change in the file format and layout was introduced with the version jump from 0.7 to 0.10. Due to the maturity of Maven and SBT being rather young, it has also been said that Maven provides a greater number of plugins and that SBT's documentation is lacking, although others say that the quality of documentation is improving.[12][13]

The SBT project uses SBT to build itself, and considers that dogfooding is a positive feature. To the Debian project, however, that is considered a circular dependency, that they try to minimize. As a result, SBT is not a Debian package.[14]

References

  1. [1]
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Public repositories hosted on github which mention sbt
  5. Getting started for Lift
  6. 6.0 6.1 Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. Lua error in package.lua at line 80: module 'strict' not found.
  9. sbt: Basic Configuration
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. Lua error in package.lua at line 80: module 'strict' not found.
  12. Lua error in package.lua at line 80: module 'strict' not found.
  13. Lua error in package.lua at line 80: module 'strict' not found. This is a blog entry giving context to a linked e-mail in which problems with sbt are outlined.
  14. Lua error in package.lua at line 80: module 'strict' not found., includes conversation with an SBT developer.

See also

External links