github sbt/sbt v1.5.0-M2
1.5.0-M2

latest releases: v1.10.2, v1.10.1, v1.10.0...
3 years ago

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

Don't miss a new sbt release

NewReleases is sending notifications on new releases.