Jump to content

sbt (software)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Vt320 (talk | contribs) at 11:21, 14 July 2020 (update to scala 1.3.13). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

sbt
Original author(s)Mark Harrah
Developer(s)Lightbend and the community
Stable release
1.3.13[1] / June 27, 2020; 4 years ago (2020-06-27) [2]
Repository
Written inScala
Operating systemCross-platform
PlatformJava
TypeBuild automation
LicenseBSD License
Websitescala-sbt.org

sbt is an open-source build tool for Scala and Java projects, similar to Apache's Maven and Ant.

Its main features are:

  • Native support for compiling Scala code and integrating with many Scala test frameworks
  • Continuous compilation, testing, and deployment
  • Incremental testing and compilation (only changed sources are re-compiled, only affected tests are re-run etc.)
  • Build descriptions written in Scala using a DSL
  • Dependency management using Apache Ivy (which supports Maven-format repositories)
  • Integration with the Scala interpreter for rapid iteration and debugging
  • Support for mixed Java/Scala projects

sbt is the de facto build tool in the Scala community,[3] used by the Lift web framework[4] and Play Framework.

Scala's commercial outlet, Lightbend Inc., has called sbt "arguably the best tool for building Scala projects", saying that its two most prominent features are incremental compilation and an interactive shell.[5] When continuous compilation mode is entered, the Scala compiler is instantiated only once, 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.[6] The popularity of the incremental compilation has prompted Typesafe to extract this feature in the form of an independent component called Zinc.[5]

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

History

sbt was first publicly announced on 18 December 2008 by Mark Harrah — its original author. It was initially an abbreviation that stood for "Simple Build Tool", but it is now known simply as "sbt".[8]

Build files

An sbt build can be defined using a .sbt file [9] Below is an example of build.sbt build definition:

val scalaTest   = "org.scalatest" %% "scalatest" % "3.0.5"
val akkaVersion = "2.4.2"
val akkaActor   = "com.typesafe.akka" %% "akka-actor" % akkaVersion
val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akkaVersion

// Set the Scala version used by this build to 2.12.8.
ThisBuild / scalaVersion := "2.12.8"
ThisBuild / version      := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"

lazy val root = (project in file("."))
  .aggregate(helloCore)
  .dependsOn(helloCore)
  .settings(
    name := "Hello",
    // Add a single dependency, for tests.
    libraryDependencies += scalaTest % Test
  )

lazy val helloCore = (project in file("core"))
  .settings(
    name := "Hello Core",
    libraryDependencies += scalaTest % Test,
    // Add multiple dependencies.
    libraryDependencies ++= List(akkaActor, akkaCluster)
  )

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 Apache 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]

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 yet in Debian.[13]

See also

References

  1. ^ [1]
  2. ^ eed3si9n (2020-06-27). "Announce: sbt 1.3.13".{{cite web}}: CS1 maint: numeric names: authors list (link)
  3. ^ Public repositories hosted on github which mention sbt
  4. ^ Getting started for Lift
  5. ^ a b "Zinc and Incremental Compilation". typesafe's blog. 13 August 2012. Retrieved 22 August 2012.
  6. ^ Goldin, Evgeny. "sbt Scala Build Tool". Retrieved 7 May 2012.
  7. ^ "Scala 2.9.0 final". 12 May 2011. Retrieved 22 August 2012.
  8. ^ Frequently Asked Questions
  9. ^ sbt: .sbt build definition
  10. ^ "Plugins". sbt. Retrieved 17 October 2014.
  11. ^ "sbt Community Plugins". Retrieved 17 October 2014.
  12. ^ Coda Hale (29 November 2011). "The Rest Of The Story". Retrieved 22 August 2012. This is a blog entry giving context to a linked e-mail in which problems with sbt are outlined.
  13. ^ "Debian Bug report logs - #639910, RFP: simple-build-tool -- for scala and java projects". Retrieved 28 Jun 2015., includes conversation with an sbt developer.