Sbt (software)

Last updated
sbt
Original author(s) Mark Harrah
Developer(s) Eugene Yokota and community
Stable release
1.9.7 [1] / October 22, 2023;20 days ago (2023-10-22) [2]
Repository
Written in Scala
Operating system Cross-platform
Platform Java
Type Build automation
License BSD License
Website scala-sbt.org

sbt (originally Simple Build Tool, nowadays often believed to stand for Scala Build Tool or used as its own proper name [3] ) is an open-source build tool created explicitly for Scala and Java projects. It aims to streamline the procedure of constructing, compiling, testing, and packaging applications, libraries, and frameworks. sbt is highly adaptable, permitting developers to customize the build process according to their project's specific needs.

Contents

sbt provides a wide range of features to make the process of building and managing Scala projects easy and efficient. [4] Some of the key features include:

sbt is the de facto build tool in the Scala community, [5] used, for example, by the Scala 2 and Scala 3 compilers themselves, [6] [7] Play Framework, and Lichess, a popular chess server. The sbt project is "bootstrapped" — it uses sbt to build itself and considers dogfooding a positive feature.

History

sbt was originally released as an open-source project by Mark Harrah in 2008. [8] Over the years, it has evolved significantly through numerous releases, each introducing new features, bug fixes, and enhancements. Here is an overview of the significant releases, along with the key changes and innovations they introduced: [9]

  1. sbt 0.3.2 (2008): This was the first official release of sbt. It introduced rudimentary features such as project definition, dependency management, and compilation.
  2. sbt 0.7 (2009): Established the basic framework for constructing and managing Scala projects. Key features included incremental compilation, dependency management, and straightforward task execution.
  3. sbt 0.10 (2011): Introduced a significant overhaul of the build definition syntax, making it more expressive and flexible. There were also enhancements in performance, dependency management, and configuration.
  4. sbt 0.12 (2012): Improved support for multi-module projects, the ability to define custom configurations, and simplified plugin development.
  5. sbt 0.13 (2013): Focused on usability and performance. This version introduced Activator, [10] a web-based tool for creating and managing projects. Other features included incremental macro compilation, improved handling of build definition errors, and various performance optimizations. 0.13 remained the main sbt version for the next four years.
  6. sbt 1.0 (2017): Introduced substantial changes to the sbt codebase, focusing on performance and stability, but also attempted to maintain compatibility with older versions as much as possible. New features included unified slash syntax for defining tasks and settings, improved dependency management, and Scala 2.12 as the language version used for build definitions. Furthermore, the switch to the new Zinc 1.0 incremental compiler further boosted incremental compilation performance. [11]
  7. sbt 1.1 (2018): This release launched the sbt server, enabling IDEs and other tools to interact with sbt via the Language Server Protocol (LSP). It also added cross-building support for Scala.js [12] and Scala Native [13] and improved the performance of various tasks.
  8. sbt 1.3 (2019): This version significantly improved the user experience by speeding up dependency resolution by adopting Coursier [14] as the default dependency manager. Further enhancements included improvements to the build caching mechanism and support for JDK 11.
  9. sbt 1.5 (2021): Added support for Scala 3. Enhancements were also made to the BSP (Build Server Protocol) support, [15] enabling better integration with IDEs.
  10. sbt 1.8 (2022): This release brought updates to Coursier and improved Ivy support.
  11. sbt 1.9 (2023): More updates to Coursier and a text-based menu to help with creating new projects.

Build files

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

valscalaTest="org.scalatest"%%"scalatest"%"3.2.14"valakkaVersion="2.6.20"valakkaActor="com.typesafe.akka"%%"akka-actor"%akkaVersionvalakkaCluster="com.typesafe.akka"%%"akka-cluster"%akkaVersion// Set the Scala version used by this build to 2.13.10.ThisBuild/scalaVersion:="2.13.10"ThisBuild/version:="0.1.0-SNAPSHOT"ThisBuild/organization:="com.example"lazyvalroot=(projectinfile(".")).aggregate(helloCore).dependsOn(helloCore).settings(name:="Hello",// Add a single dependency, for tests.libraryDependencies+=scalaTest%Test)lazyvalhelloCore=(projectinfile("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:

$sbtclean 

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. [17] Community-contributed plugins cover areas such as signing, packaging, publishing and releasing artifacts, connecting to other services such as blogs and databases, or integrating with other technologies.

Both IntelliJ IDEA and VS Code support sbt through their Scala plugins. In both those IDEs, it is possible to create a new project with initial sbt build files, as well as if the project already includes an sbt build file, it can be used to generate the project's configuration for the given IDE.

Comparisons

The main alternatives for sbt among build tools are Gradle and Apache Maven, both established build tools for projects developed on the JVM platform. In the Scala ecosystem, another popular build tool is Mill. [18] The choice between sbt, Gradle, Apache Maven, and Mill, depends on the specific requirements of your project and your familiarity with the tools. If you're working primarily with Scala, sbt or Mill might prove a better fit, while if you're working with multiple languages or technologies, one of the other two may be a better choice.

sbtGradleMavenMill
Language and target audienceSpecifically designed for Scala and Java projects. Offers features that cater to the unique needs of the Scala ecosystem. Sees the most frequent usage in Scala projects.General-purpose, supporting multiple languages, including Java, Groovy, Kotlin, Scala, and more. Sees the most frequent usage in Java and Kotlin projects.Used for Java projects but can also support other programming languages via plugins like Scala, Groovy, and Kotlin. Sees the most frequent usage in Java projects.Primarily targets Scala, but it does have support for compiling Java code in mixed Scala/Java projects. Sees the most frequent usage in Scala projects and is particularly appealing to developers who value simplicity and predictability in their build tool.
Build file syntaxBuild files are written in Scala, leveraging Scala's expressiveness and type safety during build definition.Build files can be written in either Groovy or Kotlin. Syntax tends to lean towards being more declarative.Uses XML for writing Project Object Model (POM) files. Syntax is more verbose and declarative, favoring a standardized project structure and a convention over configuration.Uses plain Scala for its build files. Its build definitions are written as Scala object definitions and the tasks are defined as methods within those objects.
Incremental compilationFeatures incremental compilation, compiling only the sections of the code that have changed and thus speeding up the development process.Also supports incremental compilation for Java and Kotlin projects, but its capability for Scala incremental compilation is not as well developed as sbt's.By default, it does not support incremental compilation. It can be enabled via plugins like scala-maven-plugin for Scala projects or the incremental compilation feature of java-compiler-plugin for Java projects.Features incremental compilation. Additionally, uses aggressive caching of task outputs and isolated environments for each task, which further improves the speed and accuracy of builds.
Extensibility and pluginsOffers an extensive plugin ecosystem, allowing developers to enlarge the build tool's functionality.Due to its wider acceptance across numerous languages and platforms, Gradle's plugin ecosystem is more extensive and varied than sbt's.Has a larger and more mature plugin ecosystem than sbt due to its extensive history and wide acceptance within the Java community.Has a smaller plugin ecosystem than sbt, but supports extensibility in a different way:

In Mill, you can define reusable modules and libraries directly in your build files, in plain Scala. You can also import and use third-party Scala libraries in your build files.

PerformanceEmploys performance optimizations like incremental compilation and parallel task execution, but the results vary depending on project complexity and specific use cases.Emphasizes performance, utilizing a daemon process running in the background to accelerate builds.By default, it doesn't support incremental compilation, nor parallel execution. Both can be achieved using plugins and build tool options.Supports incremental compilation and parallel execution. Is generally considered to take a more aggressive approach to caching, which often leads to faster incremental build times compared to sbt, especially for larger projects.
Build lifecycleUses complex DSL ( Domain Specific Language) for build definitions, offering more granular control over the build process.Its DSL is simpler than sbt's, more declarative and may feel more intuitive for beginners.Introduces a fixed build lifecycle consisting of well-defined phases such as compile, test, package, install, etc. Through this, Maven provides a consistent structure across projects but lacks flexibility.Builds are defined in terms of tasks. Each task represents a unit of work in a build, like compiling a module, running tests, creating a package, etc. Tasks can depend on other tasks. Mill takes care of running the tasks in the right order.
CommunityHas an active, supportive community, primarily concentrated on the Scala programming language.Its community is more extensive and diverse than sbt's, focusing on various programming languages and technologies.Its community is larger and more diverse, addressing multiple programming languages and technologies.Mill is an actively developed open-source project. The community around it is not as large or established as the community around sbt, but it is active and engaged and.

See also

Related Research Articles

<span class="mw-page-title-main">Eclipse (software)</span> Software development environment

Eclipse is an integrated development environment (IDE) used in computer programming. It contains a base workspace and an extensible plug-in system for customizing the environment. It is the second-most-popular IDE for Java development, and, until 2016, was the most popular. Eclipse is written mostly in Java and its primary use is for developing Java applications, but it may also be used to develop applications in other programming languages via plug-ins, including Ada, ABAP, C, C++, C#, Clojure, COBOL, D, Erlang, Fortran, Groovy, Haskell, JavaScript, Julia, Lasso, Lua, NATURAL, Perl, PHP, Prolog, Python, R, Ruby, Rust, Scala, and Scheme. It can also be used to develop documents with LaTeX and packages for the software Mathematica. Development environments include the Eclipse Java development tools (JDT) for Java and Scala, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others.

<span class="mw-page-title-main">IntelliJ IDEA</span> Integrated development environment

IntelliJ IDEA is an integrated development environment (IDE) written in Java for developing computer software written in Java, Kotlin, Groovy, and other JVM-based languages. It is developed by JetBrains and is available as an Apache 2 Licensed community edition, and in a proprietary commercial edition. Both can be used for commercial development.

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by The Apache Software Foundation, where it was formerly part of the Jakarta Project.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that is supporting both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are aimed to address criticisms of Java.

<span class="mw-page-title-main">Apache Ivy</span>

Apache Ivy is a transitive package 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. Ivy then resolves and downloads resources from an artifact repository: either a private repository or one publicly available on the Internet.

<span class="mw-page-title-main">Vala (programming language)</span> Programming language

Vala is an object-oriented programming language with a self-hosting compiler that generates C code and uses the GObject system.

Turbo is a set of software products and services developed by the Code Systems Corporation for application virtualization, portable application creation, and digital distribution. Code Systems Corporation is an American corporation headquartered in Seattle, Washington, and is best known for its Turbo products that include Browser Sandbox, Turbo Studio, TurboServer, and Turbo.

This is a compendium of continuous integration software that supports a software engineering practice, continuous integration, in which developers' changes are immediately tested and reported when they are added to the mainline code base. The comparison of various continuous integration tools is done on the basis of platform, license, builders and Integration IDEs.

<span class="mw-page-title-main">Spring Roo</span> Open-source software tool

Spring Roo is an open-source software tool that uses convention-over-configuration principles to provide rapid application development of Java-based enterprise software. The resulting applications use common Java technologies such as Spring Framework, Java Persistence API, Thymeleaf, Apache Maven and AspectJ. Spring Roo is a member of the Spring portfolio of projects.

<span class="mw-page-title-main">Play Framework</span> Open-source web framework written in Scala

Play Framework is an open-source web application framework which follows the model–view–controller (MVC) architectural pattern. It is written in Scala and usable from other programming languages that are compiled to JVM bytecode, e.g. Java. It aims to optimize developer productivity by using convention over configuration, hot code reloading and display of errors in the browser.

<span class="mw-page-title-main">Gradle</span> Free software build automation tool

Gradle is a build automation tool for multi-language software development. It controls the development process in the tasks of compilation and packaging to testing, deployment, and publishing. Supported languages include Java, C/C++, and JavaScript. Gradle builds on the concepts of Apache Ant and Apache Maven, and introduces a Groovy- and Kotlin-based domain-specific language contrasted with the XML-based project configuration used by Maven. Gradle uses a directed acyclic graph to determine the order in which tasks can be run, through providing dependency management. It runs on the Java Virtual Machine.

Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications.

<span class="mw-page-title-main">Akka (toolkit)</span> Open-source runtime

Akka is a source-available toolkit and runtime simplifying the construction of concurrent and distributed applications on the JVM. Akka supports multiple programming models for concurrency, but it emphasizes actor-based concurrency, with inspiration drawn from Erlang.

Lightbend, formerly known as Typesafe, is a company founded by Martin Odersky, the creator of the Scala programming language, Jonas Bonér, the creator of the Akka middleware, and Paul Phillips in 2011.

<span class="mw-page-title-main">Gatling (software)</span>

Gatling is a load- and performance-testing framework based on Scala, Akka and Netty. The first stable release was published on January 13, 2012. In 2015, Gatling's founder, Stéphane Landelle, created a company, dedicated to the development of the open-source project. According to Gatling Corp's official blog, Gatling was downloaded more than 1,000,000 times (2021). In June 2016, Gatling officially presented Gatling FrontLine, Gatling's Enterprise Version with additional features.

Kotlin is a cross-platform, statically typed, general-purpose high-level programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more concise. Kotlin mainly targets the JVM, but also compiles to JavaScript or native code via LLVM. Language development costs are borne by JetBrains, while the Kotlin Foundation protects the Kotlin trademark.

<span class="mw-page-title-main">Bazel (software)</span> Software tool that automates software builds and tests

Bazel is a free and open-source software tool used for the automation of building and testing software. Google uses the build tool Blaze internally and released an open-sourced port of the Blaze tool as Bazel, named as an anagram of Blaze. Bazel was first released in March 2015 and was in beta status by September 2015. Version 1.0 was released in October 2019.

<span class="mw-page-title-main">PureScript</span> Strongly-typed language that compiles to JavaScript

PureScript is a strongly-typed, purely-functional programming language that transpiles to JavaScript, C++11, Erlang, and Go. It can be used to develop web applications, server side apps, and also desktop applications with use of Electron or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that of Haskell. In addition, it introduces row polymorphism and extensible records. Also, contrary to Haskell, the PureScript language is defined as having a strict evaluation strategy, although there are non-conforming back ends which implement a lazy evaluation strategy.

References

  1. eed3si9n (2023-10-22). "Releases". github.com. Retrieved 2023-11-11.
  2. eed3si9n (2023-10-22). "1.9.7". github.com. Retrieved 2023-11-11.
  3. "sbt Reference Manual — Frequently Asked Questions". www.scala-sbt.org. Retrieved 2023-06-15.
  4. "sbt Reference Manual — sbt Reference Manual". www.scala-sbt.org. Retrieved 2023-06-15.
  5. "Build software better, together". GitHub. Retrieved 2023-06-15.
  6. Welcome!, The Scala Programming Language, 2023-06-14, retrieved 2023-06-15
  7. Dotty, Programming Methods Laboratory EPFL, 2023-06-14, retrieved 2023-06-15
  8. "sbt Reference Manual — Developer's Guide (Work in progress)". www.scala-sbt.org. Retrieved 2023-06-15.
  9. "Releases · sbt/sbt". GitHub. Retrieved 2023-06-15.
  10. Inc, Lightbend. "Typesafe Activator 1.3.0 released: Contains new sbt server and UI | @lightbend". Lightbend. Retrieved 2023-06-15.{{cite web}}: |last= has generic name (help)
  11. "Speed up compile times with Zinc 1.0". www.scala-lang.org. Retrieved 2023-06-15.
  12. "Scala.js". Scala.js. Retrieved 2023-06-15.
  13. "Scala Native — Scala Native 0.4.14 documentation". scala-native.org. Retrieved 2023-06-15.
  14. "Coursier · Pure Scala Artifact Fetching". get-coursier.io. Retrieved 2023-06-15.
  15. "Build Server Protocol". build-server-protocol.github.io. Retrieved 2023-06-15.
  16. sbt: .sbt build definition
  17. "Plugins". sbt. Retrieved 17 October 2014.
  18. "Introduction to Mill :: Mill". mill-build.com. Retrieved 2023-06-15.