Merge pull request #3375 from sbt/0.13.16

Merge 0.13.16
This commit is contained in:
Dale Wijnand 2017-07-27 07:09:54 +01:00 committed by GitHub
commit 3d50ca2f6a
9 changed files with 139 additions and 60 deletions

View File

@ -60,6 +60,36 @@ object CrossVersionTest extends Specification {
"return binary sbt version for 0.12.1 as 0.12" in {
CrossVersion.binarySbtVersion("0.12.1") must_== "0.12"
}
"return binary sbt version for 1.0.0-M6 as 1.0.0-M6" in {
CrossVersion.binarySbtVersion("1.0.0-M6") must_== "1.0.0-M6"
}
"return binary sbt version for 1.0.0-RC1 as 1.0" in {
CrossVersion.binarySbtVersion("1.0.0-RC1") must_== "1.0"
}
"return binary sbt version for 1.0.0 as 1.0" in {
CrossVersion.binarySbtVersion("1.0.0") must_== "1.0"
}
"return binary sbt version for 1.0.2-M1 as 1.0" in {
CrossVersion.binarySbtVersion("1.0.2-M1") must_== "1.0"
}
"return binary sbt version for 1.0.2-RC1 as 1.0" in {
CrossVersion.binarySbtVersion("1.0.2-RC1") must_== "1.0"
}
"return binary sbt version for 1.0.2 as 1.0" in {
CrossVersion.binarySbtVersion("1.0.2") must_== "1.0"
}
"return binary sbt version for 1.3.0 as 1.0" in {
CrossVersion.binarySbtVersion("1.3.0") must_== "1.0"
}
"return binary sbt version for 1.3.0-SNAPSHOT as 1.0" in {
CrossVersion.binarySbtVersion("1.3.0-SNAPSHOT") must_== "1.0"
}
"return binary sbt version for 1.10.0 as 1.0" in {
CrossVersion.binarySbtVersion("1.10.0") must_== "1.0"
}
"return binary sbt version for 2.0.0 as 2.0" in {
CrossVersion.binarySbtVersion("2.0.0") must_== "2.0"
}
"return Scala API for xyz as None" in {
CrossVersion.scalaApiVersion("xyz") must_== None
@ -121,11 +151,9 @@ object CrossVersionTest extends Specification {
"return binary Scala version for 2.20170314093845.0-87654321 as 2.20170314093845.0-87654321" in {
CrossVersion.binaryScalaVersion("2.20170314093845.0-87654321") must_== "2.20170314093845.0-87654321"
}
"return binary Scala version for Dotty 0.1.1 as 0.1" in {
CrossVersion.binaryScalaVersion("0.1.1") must_== "0.1"
}
"return patch Scala version for 2.11.8 as 2.11.8" in {
CrossVersion(CrossVersion.patch, "2.11.8", "dummy").map(_("artefact")) must_== Some("artefact_2.11.8")
}

View File

@ -0,0 +1,14 @@
package sbt
import scala.annotation.Annotation
/**
* An annotation to designate that the annotated entity
* should not be considered for additional sbt compiler checks.
* These checks ensure that the DSL is predictable and prevents
* users from doing dangerous things at the cost of a stricter
* code structure.
*
* @since 0.13.16
*/
class sbtUnchecked extends Annotation

View File

@ -244,7 +244,6 @@ object Defaults extends BuildCommon {
sbt.inc.ClassfileManager.transactional(crossTarget.value / "classes.bak", sbt.Logger.Null)),
scalaInstance := scalaInstanceTask.value,
crossVersion := (if (crossPaths.value) CrossVersion.binary else CrossVersion.Disabled),
scalaVersion := PluginCross.scalaVersionSetting.value,
sbtBinaryVersion in pluginCrossBuild := binarySbtVersion((sbtVersion in pluginCrossBuild).value),
crossSbtVersions := Vector((sbtVersion in pluginCrossBuild).value),
crossTarget := makeCrossTarget(target.value,

View File

@ -41,9 +41,10 @@ private[sbt] object PluginCross {
import x._
state.log.info(s"Setting `sbtVersion in pluginCrossBuild` to $version")
val add = List(sbtVersion in GlobalScope in pluginCrossBuild :== version) ++
inConfig(Compile)(List(scalaVersion := scalaVersionSetting.value)) ++
inConfig(Test)(List(scalaVersion := scalaVersionSetting.value))
List(scalaVersion := scalaVersionSetting.value) ++
inScope(GlobalScope.copy(project = Select(currentRef)))(Seq(
scalaVersion := scalaVersionSetting.value
))
val cleared = session.mergeSettings.filterNot(crossExclude)
val newStructure = Load.reapply(cleared ++ add, structure)
Project.setProject(session, newStructure, command :: state)

View File

@ -1,55 +1,21 @@
### Fixes with compatibility implications
- Removes the "hit \[ENTER\] to switch to interactive mode" feature. See below.
- Removes the "hit \[ENTER\] to switch to interactive mode" feature. Run `sbt xxx shell` to stay in shell after `xxx`. [#3091][3091]/[#3153][3153] by [@dwijnand][@dwijnand]
### Improvements
- Improves the new startup messages. See below.
- Ports sbt-cross-building's `^` and `^^` commands for plugin cross building. See below.
- Adds `Zero` scope component for sbt 1.0 compatibility. [#3179][3179] by [@eed3si9n][@eed3si9n]
- Backports `withXXX` methods for `ModuleID` and `Artifact` for sbt 1.0 compatibility. [#3215][3215] by [@eed3si9n][@eed3si9n]
### Bug fixes
- Fixes the new startup messages. See below.
### Improvements and bug fixes to the new startup messages
The two new startup messages introduced in sbt 0.13.15 are:
- when writing out `sbt.version`, for build reproducability, and
- when informing the user about sbt's shell, for the performance improvement
When writing out `sbt.version` the messaging now:
- correctly uses a logger rather than println
- honours the log level set, for instance by `--error`
- never executes when sbt "new" is being run
When informing the user about sbt's shell the messaging now:
- is a 1 line message, rather than 3
- is at info level, rather than warn level
- can be suppressed with `suppressSbtShellNotification := true`
- only triggers when `compile` is being run
- never shows when sbt `new` is being run
[#3091][3091]/[#3097][3097]/[#3147][3147] by [@dwijnand][@dwijnand]
### Remove the "hit \[ENTER\] to switch to interactive mode" feature
In sbt 0.13.15, in addition to notifying the user about the existence of sbt's shell, a feature was added to
allow the user to switch to sbt's shell - a more pro-active approach to just displaying a message.
Unfortunately sbt is often unintentionally invoked in shell scripts in "interactive mode" when no interaction is
expected by, for exmaple, invoking `sbt package` instead of `sbt package < /dev/null`. In that case hitting
\[ENTER\] would silently trigger sbt to run its shell, easily wrecking the script. In addition to that I was
unhappy with the implementation as it created a tight coupling between sbt's command processing abstraction to
sbt's shell command.
If you want to stay in sbt's shell after running a task like `package` then invoke sbt like so:
sbt package shell
[#3091][3091]/[#3153][3153] by [@dwijnand][@dwijnand]
- Fixes forward compatibility of Scripted plugin with sbt 1.0.0-RC2. [#3329][3329] by [@dwijnand][@dwijnand]
- Fixes ScalaTest nested suite test names being reported as "(It is not a test)". [#3154][3154] by [@jameskoch][@jameskoch]
- Fixes default `scalaBinaryVersion` for Dotty. [#3152][3152] by [@smarter][@smater]
- Updates JLine dependency to 2.14.4 to work around ncurses change causing `NumberFormatException`. [#3265][3265] by [@Rogach][@Rogach]
### sbt-cross-building
@ -61,18 +27,18 @@ sbt 0.13.16 merges these commands into sbt because the feature it provides is us
To switch the `sbtVersion in pluginCrossBuild` from the shell use:
```
^^ 1.0.0-M5
^^ 1.0.0-RC2
```
Your plugin will now build with sbt 1.0.0-M5 (and its Scala version 2.12.2).
Your plugin will now build with sbt 1.0.0-RC2 (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.
and `src/main/scala-sbt-1.0`, where the binary sbt version number is used as postfix.
To run a command across multiple sbt versions, set:
```scala
crossSbtVersions := Vector("0.13.15", "1.0.0-M5")
crossSbtVersions := Vector("0.13.15", "1.0.0-RC2")
```
Then, run:
@ -83,11 +49,56 @@ Then, run:
[#3133][3133] by [@eed3si9n][@eed3si9n]
#### Eviction warning presentation
sbt 0.13.16 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
[#3202][3202] by [@eed3si9n][@eed3si9n]
### Improvements and bug fixes to the startup messages
sbt writes out the `sbt.version` in `project/build.properties` if it is missing.
sbt 0.13.16 fixes the logging when it happens by using the logger.
We encourage the use of the sbt shell by running `sbt`, instead of running `sbt compile` from the terminal repreatedly.
The sbt shell keeps the JVM warm, and there is a significant performance improvement gained for your compilation.
The startup message that we added in sbt 0.13.15 was a bit too aggressive, so we are toning it down in 0.13.16.
It will only be triggered for `sbt compile`, and it can also be supressed with `suppressSbtShellNotification := true`.
[#3091][3091]/[#3097][3097]/[#3147][3147] by [@dwijnand][@dwijnand]
[3091]: https://github.com/sbt/sbt/issues/3091
[3097]: https://github.com/sbt/sbt/issues/3097
[3147]: https://github.com/sbt/sbt/pull/3147
[3133]: https://github.com/sbt/sbt/pull/3133
[3153]: https://github.com/sbt/sbt/pull/3153
[3152]: https://github.com/sbt/sbt/pull/3152
[3179]: https://github.com/sbt/sbt/pull/3179
[3202]: https://github.com/sbt/sbt/pull/3202
[3215]: https://github.com/sbt/sbt/pull/3215
[3265]: https://github.com/sbt/sbt/pull/3265
[3329]: https://github.com/sbt/sbt/pull/3329
[@jrudolph]: https://github.com/jrudolph
[@eed3si9n]: https://github.com/eed3si9n
[@dwijnand]: https://github.com/dwijnand
[@jameskoch]: https://github.com/jameskoch
[@smarter]: https://github.com/smarter
[@Rogach]: https://github.com/Rogach

View File

@ -1,5 +0,0 @@
### Bug fixes
- Fixes ScalaTest nested suite test names being reported as "(It is not a test)". [#3154][3154] by [@jameskoch][@jameskoch]
[@jameskoch]: https://github.com/jameskoch

View File

@ -1,5 +1,9 @@
val baseSbt = "0.13"
val buildCrossList = List("2.10.6", "2.11.11", "2.12.2")
scalaVersion in ThisBuild := "2.10.6"
crossScalaVersions in ThisBuild := buildCrossList
lazy val root = (project in file("."))
.settings(
sbtPlugin := true,
@ -11,6 +15,12 @@ lazy val root = (project in file("."))
assert(sv == "2.10", s"Wrong e:scalaVersion: $sv")
assert(scalaBinaryVersion.value == "2.10", s"Wrong Scala binary version: ${scalaBinaryVersion.value}")
assert(crossV startsWith "0.13", s"Wrong `sbtVersion in pluginCrossBuild`: $crossV")
// crossScalaVersions in app should not be affected
val appCrossScalaVersions = (crossScalaVersions in app).value.toList
val appScalaVersion = (scalaVersion in app).value
assert(appCrossScalaVersions == buildCrossList, s"Wrong `crossScalaVersions in app`: $appCrossScalaVersions")
assert(appScalaVersion startsWith "2.10", s"Wrong `scalaVersion in app`: $appScalaVersion")
},
TaskKey[Unit]("check2") := {
@ -20,5 +30,13 @@ lazy val root = (project in file("."))
assert(sv == "2.12", s"Wrong e:scalaVersion: $sv")
assert(scalaBinaryVersion.value == "2.12", s"Wrong Scala binary version: ${scalaBinaryVersion.value}")
assert(crossV startsWith "1.0.", s"Wrong `sbtVersion in pluginCrossBuild`: $crossV")
// ^^ should not affect app's crossScalaVersions
val appCrossScalaVersions = (crossScalaVersions in app).value.toList
val appScalaVersion = (scalaVersion in app).value
assert(appCrossScalaVersions == buildCrossList, s"Wrong `crossScalaVersions in app`: $appCrossScalaVersions")
assert(appScalaVersion startsWith "2.10", s"Wrong `scalaVersion in app`: $appScalaVersion")
}
)
lazy val app = (project in file("app"))

View File

@ -1,5 +1,5 @@
> check
> ^^ 1.0.0-M5
> ^^ 1.0.0-RC2
> check2

View File

@ -30,12 +30,25 @@ object CrossVersionUtil
val CandidateV = (basicVersion + """(-RC\d+)""").r
val NonReleaseV = (basicVersion + """([-\w+]*)""").r
v match {
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
case ReleaseV(x, y, z, ht) => Some(sbtApiVersion(x.toInt, y.toInt))
case CandidateV(x, y, z, ht) => Some(sbtApiVersion(x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if x.toInt == 0 && z.toInt > 0 =>
Some(sbtApiVersion(x.toInt, y.toInt))
case NonReleaseV(x, y, z, _) if x.toInt > 0 && (y.toInt > 0 || z.toInt > 0) =>
Some(sbtApiVersion(x.toInt, y.toInt))
case _ => None
}
}
private[${{cross.package0}}] def sbtApiVersion(x: Int, y: Int): (Int, Int) = {
// Prior to sbt 1 the "sbt api version" was the X.Y in the X.Y.Z version.
// For example for sbt 0.13.x releases, the sbt api version is 0.13
// As of sbt 1 it is now X.0.
// This means, for example, that all versions of sbt 1.x have sbt api version 1.0
if (x > 0) (x, 0)
else (x, y)
}
private[${{cross.package0}}] def isScalaApiCompatible(v: String): Boolean = scalaApiVersion(v).isDefined
/** Returns Scala binary interface x.y API compatible with the given version string v.
* Compatibile versions include 2.10.0-1 and 2.10.1-M1 for Some(2, 10), but not 2.10.0-RC1.