From 3cd2a979cadb254f3c686c0e6c1ba36187f76ff0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 19 Jul 2017 13:35:27 +0100 Subject: [PATCH 1/5] Add `@sbtUnchecked` to sbt 0.13.16 Fixes #3337 --- main/settings/src/main/scala/sbt/sbtUnchecked.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 main/settings/src/main/scala/sbt/sbtUnchecked.scala diff --git a/main/settings/src/main/scala/sbt/sbtUnchecked.scala b/main/settings/src/main/scala/sbt/sbtUnchecked.scala new file mode 100644 index 000000000..1fb53b8c8 --- /dev/null +++ b/main/settings/src/main/scala/sbt/sbtUnchecked.scala @@ -0,0 +1,13 @@ +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 From 63867968bb8d9473d8460f8499739c5ef864d17a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 22 Jul 2017 13:20:05 -0400 Subject: [PATCH 2/5] notes --- notes/0.13.16.markdown | 101 ++++++++++-------- .../junit-report-nested-suites.markdown | 5 - 2 files changed, 56 insertions(+), 50 deletions(-) delete mode 100644 notes/0.13.16/junit-report-nested-suites.markdown diff --git a/notes/0.13.16.markdown b/notes/0.13.16.markdown index 1f91ae735..0906e0e80 100644 --- a/notes/0.13.16.markdown +++ b/notes/0.13.16.markdown @@ -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 diff --git a/notes/0.13.16/junit-report-nested-suites.markdown b/notes/0.13.16/junit-report-nested-suites.markdown deleted file mode 100644 index 2b84eeee0..000000000 --- a/notes/0.13.16/junit-report-nested-suites.markdown +++ /dev/null @@ -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 From c3ebcd64d820232d9aba8c6b036de0f23cfeaf9f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 23 Jul 2017 02:34:36 -0400 Subject: [PATCH 3/5] Fixes sbtApiVersion logic The NonRelease pattern matcher is ony checking for the third segment, but for sbt 1.x, we need to check both the second and third segment since 1.1.0-M1 would be bincompat with 1.0. Fixes sbt/sbt#3360 --- ivy/src/test/scala/CrossVersionTest.scala | 32 +++++++++++++++++-- .../main/input_sources/CrossVersionUtil.scala | 19 +++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ivy/src/test/scala/CrossVersionTest.scala b/ivy/src/test/scala/CrossVersionTest.scala index e1b1f68ef..d93868553 100644 --- a/ivy/src/test/scala/CrossVersionTest.scala +++ b/ivy/src/test/scala/CrossVersionTest.scala @@ -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") } diff --git a/util/cross/src/main/input_sources/CrossVersionUtil.scala b/util/cross/src/main/input_sources/CrossVersionUtil.scala index 37e655d6f..4ab3eb951 100644 --- a/util/cross/src/main/input_sources/CrossVersionUtil.scala +++ b/util/cross/src/main/input_sources/CrossVersionUtil.scala @@ -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. From c9fc72c61056f1c4391a73a0150da5ab3be9a8aa Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 25 Jul 2017 13:02:24 -0400 Subject: [PATCH 4/5] Format enforcement --- main/settings/src/main/scala/sbt/sbtUnchecked.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/settings/src/main/scala/sbt/sbtUnchecked.scala b/main/settings/src/main/scala/sbt/sbtUnchecked.scala index 1fb53b8c8..525a76c87 100644 --- a/main/settings/src/main/scala/sbt/sbtUnchecked.scala +++ b/main/settings/src/main/scala/sbt/sbtUnchecked.scala @@ -2,7 +2,8 @@ package sbt import scala.annotation.Annotation -/** An annotation to designate that the annotated entity +/** + * 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 From 23bfcf58a566ba63970acf356c2d54f976d11b4a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 25 Jul 2017 13:05:40 -0400 Subject: [PATCH 5/5] Fix ^^ and don't inject scalaVersion by default This no longer injects scalaVersion at the project level, which was interfering with crossScalaVersions delegation to ThisBuild scope. Fixes sbt/sbt#3353 --- main/src/main/scala/sbt/Defaults.scala | 1 - main/src/main/scala/sbt/PluginCross.scala | 7 ++++--- .../project/cross-plugins-defaults/build.sbt | 18 ++++++++++++++++++ .../project/cross-plugins-defaults/test | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 779fdadd8..b4b1c0f12 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -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, diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index 7324b7f0e..351e7d60e 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -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) diff --git a/sbt/src/sbt-test/project/cross-plugins-defaults/build.sbt b/sbt/src/sbt-test/project/cross-plugins-defaults/build.sbt index 5327d2d20..e33286bfb 100644 --- a/sbt/src/sbt-test/project/cross-plugins-defaults/build.sbt +++ b/sbt/src/sbt-test/project/cross-plugins-defaults/build.sbt @@ -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")) diff --git a/sbt/src/sbt-test/project/cross-plugins-defaults/test b/sbt/src/sbt-test/project/cross-plugins-defaults/test index a1d9be762..bad640e3f 100644 --- a/sbt/src/sbt-test/project/cross-plugins-defaults/test +++ b/sbt/src/sbt-test/project/cross-plugins-defaults/test @@ -1,5 +1,5 @@ > check -> ^^ 1.0.0-M5 +> ^^ 1.0.0-RC2 > check2