autoStartServer setting

sbt 1.1.1 adds a new global Boolean setting called autoStartServer, which is set to true by default.
When set to true, sbt shell will automatically start sbt server. Otherwise, it will not start the server until startSever command is issued. This could be used to opt out of server for security reasons.

Unified slash syntax for sbt shell and build.sbt

This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current <project-id>/config:intask::key, this adds
<project-id>/<config-ident>/intask/key where <config-ident> is the Scala identifier
notation for the configurations like Compile and Test. (The old shell syntax will continue to function)

The running sbt session should now queue compile, and return back with compiler warnings and errors, if any:

Content-Length: 296
Content-Type: application/vscode-jsonrpc; charset=utf-8
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:/Users/foo/work/hellotest/Hello.scala","diagnostics":[{"range":{"start":{"line":2,"character":26},"end":{"line":2,"character":27}},"severity":1,"source":"sbt","message":"object X is not a member of package foo"}]}}

Filtering scripted tests using project/build.properties

For all scripted tests in which project/build.properties exist, the value of the sbt.version property is read. If its binary version is different from sbtBinaryVersion in pluginCrossBuild the test will be skipped and a message indicating this will be logged.

This allows you to define scripted tests that track the minimum supported sbt versions, e.g. 0.13.9 and 1.0.0-RC2. #3564/#3566 by @jonas

Improvements

Adds sbt.watch.mode system property to allow switching back to old polling behaviour for watch. See below for more details.

Alternative watch mode

sbt 1.0.0 introduced a new mechanism for watching for source changes based on the NIO WatchService in Java 1.7. On
some platforms (namely macOS) this has led to long delays before changes are picked up. An alternative WatchService
for these platforms is planned for sbt 1.1.0 (#3527), in the meantime an option to select which watch service
has been added.

The new sbt.watch.mode JVM flag has been added with the following supported values:

polling: (default for macOS) poll the filesystem for changes (mechanism used in sbt 0.13).

nio (default for other platforms): use the NIO based WatchService.

If you are experiencing long delays on a non-macOS machine then try adding -Dsbt.watch.mode=polling to your sbt
options.

sbt 1.0.1

This is a hotfix release for sbt 1.0.x series.

Bug fixes

Fixes command support for cross building + command. The + added to sbt 1.0 traveres over the subprojects, respecting crossScalaVersions; however, it no longer accepted commands as arguments. This brings back the support for it. #3446 by @jroper

Fixes addSbtPlugin to use the correct version of sbt during cross building. #3442 by @dwijnand

Fixes run in Compile task not including Runtime configuration, by reimplementing run in terms of bgRun. #3477 by @eed3si9n

WatchSource

The watch source feature went through a major change from sbt 0.13 to sbt 1.0 using NIO; however, it did not have clear migration path, so we are rectifying that in sbt 1.0.1.

First, sbt.WatchSource is a new alias for sbt.internal.io.Source. Hopefully this is easy enough to remember because the key is named watchSources. Next, def apply(base: File) and def apply(base: File, includeFilter: FileFilter, excludeFilter: FileFilter) constructors were added to the companion object of sbt.WatchSource.

sbt 1.0.0

Features, fixes, changes with compatibility implications

Many of the case classes are replaced with pseudo case classes generated using Contraband. Migrate .copy(foo = xxx) to withFoo(xxx).
For example, UpdateConfiguration, RetrieveConfiguration, PublishConfiguration are refactored to use builder pattern.

Zinc 1 drops support for Scala 2.9 and earlier. Scala 2.10 must use 2.10.2 and above. Scala 2.11 must use 2.11.2 and above. (latest patch releases are recommended)

config("xyz") must be directly assigned to a capitalizedval, like val Xyz = config("xyz"). This captures the lhs identifier into the configuration so we can use it from the shell later.

A number of the methods on sbt.Path (such as relativeTo and rebase and flat) are now no longer in the
default namespace by virtue of being mixed into the sbt package object. Use sbt.io.Path to access them
again.

sbt.Process and sbt.ProcessExtra are dropped. Use scala.sys.process instead.

incOptions.value.withNameHashing(...) option is removed because name hashing is always on.

TestResult.Value is now called TestResult.

The scripted plugin is cross-versioned now, so you must use %% when depending on it.

Dropped dreprecations:

sbt 0.12 style Build trait that was deprecated in sbt 0.13.12, is removed. Please migrate to build.sbt. Auto plugins and Build trait do not work well together, and its feature is now largely subsumed by multi-project build.sbt.

sbt 0.12 style Project(...) constructor is restricted down to two parameters. This is because settings parameter does not work well with Auto Plugins. Use project instead.

sbt 0.12 style key dependency operators <<=, <+=, <++= are removed. Please migrate to :=, +=, and ++=. These operators have been sources of confusion for many users, and have long been removed from 0.13 docs, and have been formally deprecated since sbt 0.13.13.

Non-auto sbt.Plugin trait is dropped. Please migrate to AutoPlugin. Auto plugins are easier to configure, and work better with each other.

Removes the settingsSets method from Project (along with add/setSbtFiles).

The startup log level is dropped to -error in script mode using scalas. #840 by @eed3si9n

Replace cross building support with sbt-doge. This allows builds with projects that have multiple different combinations of cross scala versions to be cross built correctly. The behaviour of ++ is changed so that it only updates the Scala version of projects that support that Scala version, but the Scala version can be post fixed with ! to force it to change for all projects. A -v argument has been added that prints verbose information about which projects are having their settings changed along with their cross scala versions. #2613 by @jroper

ivyLoggingLevel is dropped to UpdateLogging.Quiet when CI environment is detected. @eed3si9n

Add logging of the name of the different build.sbt (matching *.sbt) files used. #1911 by @valydia

Add the ability to call aggregate for the current project inside a build sbt file. By @xuwei-k

Add new global setting asciiGraphWidth that controls the maximum width of the ASCII graphs printed by commands like inspect tree. Default value corresponds to the previously hardcoded value of 40 characters. By @RomanIakovlev.

Internals

Adopted Scalafmt for formatting the source code using neo-scalafmt.

Scala Center contributed a redesign of the scripted test framework that has batch mode execution. Scripted now reuses the same sbt instance to run sbt tests, which reduces the CI build times by 50% #3151 by @jvican

Details of major changes

Zinc 1: Class-based name hashing

A major improvement brought into Zinc 1.0 by Grzegorz Kossakowski (commissioned by Lightbend) is class-based name hashing, which will speed up the incremental compilation of Scala in large projects.

Zinc 1.0’s name hashing tracks your code dependendencies at the class level, instead of at the source file level. The GitHub issue sbt/sbt#1104 lists some comparisons of adding a method to an existing class in some projects:

This depends on some factors such as how your classes are organized, but you can see 3x ~ 40x improvements. The reason for the speedup is because it compiles fewer source files than before by untangling the classes from source files. In the example adding a method to scala/scala’s Platform class, sbt 0.13’s name hashing used to compile 72 sources, but the new Zinc compiles 6 sources.

Zinc API changes

Java classes under the xsbti.compile package such as IncOptions hides the constructor. Use the factory method xsbti.compile.Foo.of(...).

Renames ivyScala: IvyScala key to scalaModuleInfo: ScalaModuleInfo.

xsbti.Reporter#log(...) takes xsbti.Problem as the parameter. Call log(problem.position, problem.message, problem.severity) to delegate to the older log(...).

sbt server: JSON API for tooling integration

sbt 1.0 includes server feature, which allows IDEs and other tools to query the build for settings, and invoke commands via a JSON API. Similar to the way that the interactive shell in sbt 0.13 is implemented with shell command, “server” is also just shell command that listens to both human input and network input. As a user, there should be minimal impact because of the server.

In March 2016, we rebooted the “server” feature to make it as small as possible. We worked in collaboration with JetBrains’ @jastice who works on IntelliJ’s sbt interface to narrow down the feature list. sbt 1.0 will not have all the things we originally wanted, but in the long term, we hope to see better integration between IDE and sbt ecosystem using this system. For example, IDEs will be able to issue the compile task and retrieve compiler warning as JSON events:

{"type":"xsbti.Problem","message":{"category":"","severity":"Warn","message":"a pure expression does nothing in statement position; you may be omitting necessary parentheses","position":{"line":2,"lineContent":" 1","offset":29,"pointer":2,"pointerSpace":" ","sourcePath":"/tmp/hello/Hello.scala","sourceFile":"file:/tmp/hello/Hello.scala"}},"level":"warn"}

Another related feature that was added is the bgRun task which, for example, enables a server process to be run in the background while you run tests against it.

Static validation of build.sbt

sbt 1.0 prohibits .value calls inside the bodies of if expressions and anonymous functions in a task, @sbtUnchecked annotation can be used to override the check.

The static validation also catches if you forget to call .value in a body of a task.

Eviction warning presentation

sbt 1.0 improves the eviction warning presetation.

Before:

[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] * com.google.code.findbugs:jsr305:2.0.1 -> 3.0.0
[warn] Run 'evicted' to see detailed eviction warnings

After:

[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]
[warn] * com.typesafe.akka:akka-actor_2.12:2.5.0 is selected over 2.4.17
[warn] +- de.heikoseeberger:akka-log4j_2.12:1.4.0 (depends on 2.5.0)
[warn] +- com.typesafe.akka:akka-parsing_2.12:10.0.6 (depends on 2.4.17)
[warn] +- com.typesafe.akka:akka-stream_2.12:2.4.17 () (depends on 2.4.17)
[warn]
[warn] Run 'evicted' to see detailed eviction warnings

sbt-cross-building

@jrudolph’s sbt-cross-building is a plugin author’s plugin.
It adds cross command ^ and sbtVersion switch command ^^, similar to + and ++,
but for switching between multiple sbt versions across major versions.
sbt 0.13.16 merges these commands into sbt because the feature it provides is useful as we migrate plugins to sbt 1.0.

To switch the sbtVersion in pluginCrossBuild from the shell use:

^^ 1.0.0-M5

Your plugin will now build with sbt 1.0.0-M5 (and its Scala version 2.12.2).

If you need to make changes specific to a sbt version, you can now include them into src/main/scala-sbt-0.13,
and src/main/scala-sbt-1.0.0-M5, where the binary sbt version number is used as postfix.

Parallel artifact download for Ivy engine was contributed by Jorge (@jvican) from Scala Center.
It also introduces Gigahorse OkHttp as the Network API, and it uses Square OkHttp for artifact download as well.