Skip to content

Releases: sbt/sbt

1.5.0-M2

22 Feb 07:11
v1.5.0-M2
ab2b396

Choose a tag to compare

1.5.0-M2 is a beta release to test sbt 1.5.0. The headline feature is built-in support for Scala 3.

Scala 3 support

sbt 1.5.0 adds built-in Scala 3 support, contributed by Scala Center. Main implementation was done by Adrien Piquerez (@adpi2) based on EPFL/LAMP's sbt-dotty.

Note: Due to the transitive dependencies to Dokka, which is planned to be removed eventually, the following resolver is required to use Scala 3.0.0-RC1 for now:

ThisBuild / resolvers += Resolver.JCenterRepository

After this resolver is added, you can now use Scala 3.0.0-RC1 like any other Scala version.

ThisBuild / scalaVersion := "3.0.0-RC1"
ThisBuild / resolvers += Resolver.JCenterRepository

This will compile the following Hello.scala:

package example

@main def hello(arg: String*): Unit =
  if arg.isEmpty then println("hello")
  else println(s"hi ${arg.head}")

Scala 2.13-3.x sandwich

Scala 3.0.x shares the standard library with Scala 2.13, and since Scala 2.13.4, they can mutually consume the output of each other as external library. This allows you to create Scala 2.13-3.x sandwich, a layering of dependencies coming from different Scala versions.

Warning: Libraries such as Cats may encode a particular notion in different ways for Scala 2.13 and 3.0. For example, arity abstraction may use Shapeless HList in Scala 2.13, but built-in Tuple types in Scala 3.0. Thus it's generally not safe to have _2.13 and _3 versions of the same library in the classpath, even transitively. Library authors should generally treat Scala 3.0 as any other major version, and generally prefer to cross publish _3 variant to avoid the conflict.

sbt 1.5.0 introduces new cross building operand to use _3 variant when scalaVersion is 2.13.x, and vice versa:

("a" % "b" % "1.0").cross(CrossVersion.for3Use2_13)

("a" % "b" % "1.0").cross(CrossVersion.for2_13Use3)

lm#361 by @adpi2

Deprecation of sbt 0.13 syntax

sbt 1.5.0 deprecates both the sbt 0.13 style shell syntax proj/config:intask::key and sbt 0.13 style build.sbt DSL key in (Compile, intask) in favor of the unified slash syntax.

See https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html#slash for details.

Eviction error

sbt 1.5.0 removes eviction warning, and replaces it with stricter eviction error. Unlike the eviction warning that was based on speculation, eviction error only uses the ThisBuild / versionScheme information supplied by the library authors.

For example:

lazy val use = project
  .settings(
    name := "use",
    libraryDependencies ++= Seq(
      "org.http4s" %% "http4s-blaze-server" % "0.21.11",
      // https://repo1.maven.org/maven2/org/typelevel/cats-effect_2.13/3.0.0-M4/cats-effect_2.13-3.0.0-M4.pom
      // is published with early-semver
      "org.typelevel" %% "cats-effect" % "3.0.0-M4",
    ),
  )

The above build will fail to build use/compile with the following error:

[error] stack trace is suppressed; run last use / update for the full output
[error] (use / update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error]
[error]   * org.typelevel:cats-effect_2.12:3.0.0-M4 (early-semver) is selected over {2.2.0, 2.0.0, 2.0.0, 2.2.0}
[error]       +- use:use_2.12:0.1.0-SNAPSHOT                        (depends on 3.0.0-M4)
[error]       +- org.http4s:http4s-core_2.12:0.21.11                (depends on 2.2.0)
[error]       +- io.chrisdavenport:vault_2.12:2.0.0                 (depends on 2.0.0)
[error]       +- io.chrisdavenport:unique_2.12:2.0.0                (depends on 2.0.0)
[error]       +- co.fs2:fs2-core_2.12:2.4.5                         (depends on 2.2.0)
[error]
[error]
[error] this can be overridden using libraryDependencySchemes or evictionErrorLevel

This is because Cats Effect 2.x and 3.x are found in the classpath, and Cats Effect has declared that it uses early-semver. If the user wants to opt-out of this, the user can do so per module:

ThisBuild / libraryDependencySchemes += "org.typelevel" %% "cats-effect" % VersionScheme.Always

or globally as:

ThisBuild / evictionErrorLevel := Level.Info

On the other hand, if you want to bring back the guessing feature in eviction warning, you can do using the following settings:

ThisBuild / assumedVersionScheme := VersionScheme.PVP
ThisBuild / assumedVersionSchemeJava := VersionScheme.EarlySemVer
ThisBuild / assumedEvictionErrorLevel := Level.Warn

@eed3si9n implemented this in #6221, inspired in part by Scala Center's sbt-eviction-rules, which was implemented by Alexandre Archambault (@alxarchambault) and Julien Richard-Foy (@julienrf).

ThisBuild / packageTimestamp setting

In sbt 1.4.0 we started wiping out the timestamps in JAR to make the builds more repeatable. This had an unintended consequence of breaking Play's last-modified response header.

To opt out of this default, the user can use:

ThisBuild / packageTimestamp := Package.keepTimestamps

// or

ThisBuild / packageTimestamp := Package.gitCommitDateTimestamp

#6237 by @eed3si9n

Other updates

  • Fixes SemanticdbPlugin creating duplicate scalacOptions or dropping -Yrangepos #6296/#6316 by @bjaglin and @eed3si9n
  • Fixes tab completion of dependency configurations Compile, Test, etc #6283 by @eed3si9n
  • Fixes exit code calculation in StashOnFailure #6266 by @melezov
  • Fixes concurrency issues with testQuick #6326 by @RafalSumislawski
  • Updates to Scala 2.12.13.
  • Updates to Coursier 2.0.12, includes reload memory fix by @jtjeferreira and behind-the-proxy IntelliJ import fix added by @eed3si9n
  • Warns when ThisBuild / versionScheme is missing while publishing #6310 by @eed3si9n
  • Use 2010-01-01 for the repeatable build timestamp wipe-out to avoid negative date #6254 by @takezoe (There's an active discussion to use commit date instead)
  • Adds FileInput/FileOutput that avoids intermediate String parsing #5515 by @jtjeferreira

1.4.7

31 Jan 06:05
v1.4.7
fede746

Choose a tag to compare

1.5.0-M1

18 Jan 06:39
v1.5.0-M1
6009423

Choose a tag to compare

1.5.0-M1 Pre-release
Pre-release

1.5.0-M1 is a beta release to test sbt 1.5.0. The headline feature is built-in support for Scala 3.

Scala 3 support

sbt 1.5.0 adds built-in Scala 3 support, contributed by Scala Center. Main implementation was done by Adrien Piquerez (@adpi2) based on EPFL/LAMP's sbt-dotty.

Note: Due to the transitive dependencies to Dokka, which is planned to be removed eventually, the following resolver is required to use Scala 3.0.0-M3 for now:

ThisBuild / resolvers += Resolver.JCenterRepository

After this resolver is added, you can now use Scala 3.0.0-M3 like any other Scala version.

ThisBuild / scalaVersion := "3.0.0-M3"
ThisBuild / resolvers += Resolver.JCenterRepository

This will compile the following Hello.scala:

package example

@main def hello(arg: String*): Unit =
  if arg.isEmpty then println("hello")
  else println(s"hi ${arg.head}")

Scala 2.13-3.x sandwich

Scala 3.0.x shares the standard library with Scala 2.13, and since Scala 2.13.4, they can mutually consume the output of each other as external library. This allows you to create Scala 2.13-3.x sandwich, a layering of dependencies coming from different Scala versions.

Warning: Libraries such as Cats may encode a particular notion in different ways for Scala 2.13 and 3.0. For example, arity abstraction may use Shapeless HList in Scala 2.13, but built-in Tuple types in Scala 3.0. Thus it's generally not safe to have _2.13 and _3 versions of the same library in the classpath, even transitively. Library authors should generally treat Scala 3.0 as any other major version, and generally prefer to cross publish _3 variant to avoid the conflict.

sbt 1.5.0 introduces new cross building operand to use _3 variant when scalaVersion is 2.13.x, and vice versa:

("a" % "b" % "1.0").cross(CrossVersion.for3Use2_13)

("a" % "b" % "1.0").cross(CrossVersion.for2_13Use3)

lm#361 by @adpi2

Eviction error

sbt 1.5.0 removes eviction warning, and replaces it with stricter eviction error. Unlike the eviction warning that was based on speculation, eviction error only uses the ThisBuild / versionScheme information supplied by the library authors.

For example:

lazy val use = project
  .settings(
    name := "use",
    libraryDependencies ++= Seq(
      "org.http4s" %% "http4s-blaze-server" % "0.21.11",
      // https://repo1.maven.org/maven2/org/typelevel/cats-effect_2.13/3.0.0-M4/cats-effect_2.13-3.0.0-M4.pom
      // is published with early-semver
      "org.typelevel" %% "cats-effect" % "3.0.0-M4",
    ),
  )

The above build will fail to build use/compile with the following error:

[error] stack trace is suppressed; run last use / update for the full output
[error] (use / update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error]
[error]   * org.typelevel:cats-effect_2.12:3.0.0-M4 (early-semver) is selected over {2.2.0, 2.0.0, 2.0.0, 2.2.0}
[error]       +- use:use_2.12:0.1.0-SNAPSHOT                        (depends on 3.0.0-M4)
[error]       +- org.http4s:http4s-core_2.12:0.21.11                (depends on 2.2.0)
[error]       +- io.chrisdavenport:vault_2.12:2.0.0                 (depends on 2.0.0)
[error]       +- io.chrisdavenport:unique_2.12:2.0.0                (depends on 2.0.0)
[error]       +- co.fs2:fs2-core_2.12:2.4.5                         (depends on 2.2.0)
[error]
[error]
[error] this can be overridden using libraryDependencySchemes or evictionErrorLevel

This is because Cats Effect 2.x and 3.x are found in the classpath, and Cats Effect has declared that it uses early-semver. If the user wants to opt-out of this, the user can do so per module:

ThisBuild / libraryDependencySchemes += "org.typelevel" %% "cats-effect" % "always"

or globally as:

ThisBuild / evictionErrorLevel := Level.Info

@eed3si9n implemented this in #6221, inspired in part by Scala Center's sbt-eviction-rules, which was implemented by Alexandre Archambault (@alxarchambault) and Julien Richard-Foy (@julienrf).

Other updates

  • Use 2010-01-01 for the repeatable build timestamp wipe-out to avoid negative date #6254 by @takezoe (There's an active discussion to use commit date instead)
  • Adds FileInput/FileOutput that avoids intermediate String parsing #5515 by @jtjeferreira

1.4.6

24 Dec 09:21
v1.4.6
1760a5e

Choose a tag to compare

  • Updates to Coursier 2.0.8, which fixes the cache directory setting on Windows (fix contributed by @fthomas)
  • Fixes performance regression in shell tab completion #6214 by @eed3si9n
  • Fixes match error when using withDottyCompat lm#352 by @eed3si9n
  • Fixes thread-safety in AnalysisCallback handler zinc#957 by @dotta

1.4.5

14 Dec 07:04
v1.4.5
160349e

Choose a tag to compare

1.4.4

23 Nov 01:47
v1.4.4
2cb0bc6

Choose a tag to compare

  • Updates SemanticDB to 4.4.0 to support Scala 2.13.4 #6148 by @adpi2
  • Fixes sbt plugin cross building regression when we enabled scriptedBatchExecution by default #6091/#6151 by @xuwei-k and @eatkins
  • Fixes scala-compiler not included into the metabuild classpath #6146 by @eatkins
  • Fixes macro occasionally dropping expressions trying to work around Scala compiler displaying "a pure expression does nothing" when sbt is really doing something #6158 by @eed3si9n
  • Fixes publishing to Azure Artifacts by setting HTTP Accept header ivy#40 by @3rwww1
  • Fixes UTF-8 handling in shell and console #6106 by @eatkins
  • Fixes BSP server logging to stdout #6097 by @adpi2
  • Fixes supershell line interlacing with logs #6112 by @eatkins
  • Fixes shutdown for thin client shell #6113 by @eatkins
  • Fixes thin client sbt process startup output #6115 by @eatkins
  • Fixes background job service shutdown #6130 by @eatkins
  • Fixes logger thunk #6128 by @eatkins
  • Fixes watch when Metals sbt -bsp is in use #6129 by @eatkins
  • Fixes watch for "dumb" terminal #6107 by @eatkins
  • Refactor sbt -bsp to use NetworkClient #6114 by @eatkins
  • Adds system property sbt.build.onchange for onChangedBuildSource #6099 by @xirc
  • Don't print socket exception on exit #6108 by @eatkins

Global / localCacheDirectory for remote caching

sbt 1.4.4 adds a new Global key called localCacheDirectory. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specific caching directory.

  • Environment variable: SBT_LOCAL_CACHE
  • System property: sbt.global.localcache
  • Windows: %LOCALAPPDATA%\sbt\v1
  • macOS: $HOME/Library/Caches/sbt/v1
  • Linux: $HOME/.cache/sbt/v1

#6155 by @eed3si9n

1.4.3

16 Nov 02:54
v1.4.3
b20c2d1

Choose a tag to compare

1.4.2

02 Nov 04:44
v1.4.2
8c3f2a5

Choose a tag to compare

1.4.1

19 Oct 20:34
v1.4.1
9f7985a

Choose a tag to compare

1.4.0

05 Oct 01:07
v1.4.0
40d4e61

Choose a tag to compare

The headline features of sbt 1.4.0 are:

  • build server protocol (BSP) support
  • sbtn: a native thin client for sbt
  • build caching
  • ThisBuild / versionScheme to take the guessing out of eviction warning

How to upgrade

Download the official sbt launcher from SDKMAN or download from https://www.scala-sbt.org/download.html. This installer includes the sbtn binary.

In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties:

sbt.version=1.4.0

This mechanism allows that sbt 1.4.0 is used only for the builds that you want.

Build server protocol (BSP) support

sbt 1.4.0 adds build server protocol (BSP) support, contributed by Scala Center. Main implementation was done by Adrien Piquerez (@adpi2) based on @eed3si9n's prototype.

When sbt 1.4.0 starts, it will create a file named .bsp/sbt.json containing a machine-readable instruction on how to run sbt -bsp, which is a command line program that uses standard input and output to communicate to sbt server using build server protocol.

How to import to IntelliJ using BSP

  1. Start sbt in a terminal
  2. Open IntelliJ IDEA 2020.1.2 or later
  3. Select "Open or import", and select "BSP Project"

How to import to VS Code + Metals

  1. Delete existing .bsp, .metals, .bloop directories if any
  2. Open VS Code in the working directory
  3. Ignore the prompt to import the project
  4. Start sbt -Dsbt.semanticdb=true in the Terminal tab. Wait till it displays "sbt server started"
  5. Navigate to Metals view, and select "Restart build server"
  6. Type compile into the sbt session to generate SemanticDB files

[#5538][5538]/[#5443][5443] by [@adpi2][@adpi2]

Native thin client

sbt 1.4.0 adds an official native thin client called sbtn that supports all tasks. If you're using the official sbt launcher 1.4.0 and not the knockoff kind you can use --client option to run the native thin client:

$ sbt --client compile $ sbt --client shutdown

The native thin client will run sbt (server) as a daemon, which avoids the JVM spinup and loading time for the second call onwards. This could an option if you would like to use sbt from the system shell such as Zsh and Fish.

Remember to call sbt --client shutdown when you're done!
sbtn binary files are also available from https://github.com/sbt/sbtn-dist/releases/tag/v1.4.0

[#5620][5620] by [@eatkins][@eatkins]

ThisBuild / versionScheme

sbt 1.4.0 adds a new setting called ThisBuild / versionScheme to track version scheme of the build:

ThisBuild / versionScheme := Some("early-semver")

The supported values are "early-semver", "pvp", and "semver-spec". sbt will include this information into pom.xml and ivy.xml as a property. In addition, sbt 1.4.0 will use the information to take the guessing out of eviction warning when this information is available. [#5724][5724] by [@eed3si9n][@eed3si9n]

VirtualFile + RemoteCache

sbt 1.4.0 / Zinc 1.4.0 virtualizes the file paths tracked during incremental compilation. The benefit for this that the state of incremental compilation can shared across different machines, as long as ThisBuild / rootPaths are enumerated beforehand.

To demonstrate this, we've also added experimental cached compilation feature to sbt. All you need is the following setting:

ThisBuild / pushRemoteCacheTo := Some(MavenCache("local-cache", file("/tmp/remote-cache")))

Then from machine 1, call pushRemoteCache. This will publish the *.class and Zinc Analysis artifacts to the location. Next, from machine 2, call pullRemoteCache.

[zinc#712][zinc712]/[#5417][5417] by [@eed3si9n][@eed3si9n]

Build linting

On start up, sbt 1.4.0 checks for unused settings/tasks. Because most settings are on the intermediary to other settings/tasks, they are included into the linting by default. The notable exceptions are settings used exclusively by a command. To opt-out, you can either append it to Global / excludeLintKeys or set the rank to invisible.

[#5153][5153] by [@eed3si9n][@eed3si9n]

Conditional task

sbt 1.4.0 adds support for conditional task (or Selective task), which is a new kind of task automatically created when Def.task { ... } consists of an if-expression:

bar := {
  if (number.value < 0) negAction.value
  else if (number.value == 0) zeroAction.value
  else posAction.value
}

Unlike the regular (Applicative) task composition, conditional tasks delays the evaluation of then-clause and else-clause as naturally expected of an if-expression. This is already possible with Def.taskDyn { ... }, but unlike dynamic tasks, conditional task works with inspect command. See Selective functor for sbt for more details. [#5558][5558] by [@eed3si9n][@eed3si9n]

Incremental build pipelining

sbt 1.4.0 adds experimental incremental build pipelining. To enable build pipelining for the build:

ThisBuild / usePipelining := true

To opt-out of creating an early output for some of the subprojects:

exportPipelining := false

[#5703][5703] by [@eed3si9n][@eed3si9n]

sbt-dependency-graph is in-sourced

sbt 1.4.0 brings in Johannes Rudolph's sbt-dependency-graph plugin into the code base.
Since it injects many tasks per subprojects, the plugin is split into two parts:

  • MiniDependencyTreePlugin that is enabled by default, bringing in dependencyTree task to Compile and Test configurations
  • Full strength DependencyTreePlugin that is enabled by putting the following to project/plugins.sbt:
addDependencyTreePlugin

Fixes with compatibility implications

  • Replaces Apache Log4j with our own logger by default to avoid Appender leakage. Use ThisBuild / useLog4J := true to use Log4j. [#5731][5731] by [@eatkins][@eatkins]
  • Makes JAR file creation repeatable by sorting entry by name and dropping timestamps [#5344][5344]/[io#279][io279] by [@raboof][@raboof]
  • Loads bare settings in the alphabetic order of the build files [#2697][2697]/[#5447][5447] by [@eed3si9n][@eed3si9n]
  • Loads vals from top-to-bottom within a build file [#2232][2232]/[#5448][5448] by [@eed3si9n][@eed3si9n]
  • HTTP resolvers require explicit opt-in using .withAllowInsecureProtocol(true) [#5593][5593] by [@eed3si9n][@eed3si9n]
  • Ctrl-C during triggered execution ~ returns to the shell instead of shutting down sbt [#5804][5804] by [@eatkins][@eatkins]
  • From sbt 1.4.3, scripted tests are executed in batch by default. Use scriptedBatchExecution := false to opt-out, and scriptedParallelInstances to increase parallelism [#6054][6054] by [@eatkins][@eatkins]

Other updates

Read more