diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 2585c2c66..54c8c180a 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -39,12 +39,12 @@ import sbt.io.IO import sbt.io.syntax._ import StandardMain._ -import java.io.File +import java.io.{ File, IOException } import java.net.URI import java.util.Locale import scala.util.control.NonFatal -/** This class is the entry point for sbt.*/ +/** This class is the entry point for sbt. */ final class xMain extends xsbti.AppMain { def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = { @@ -52,13 +52,43 @@ final class xMain extends xsbti.AppMain { import BasicCommandStrings.runEarly import BuiltinCommands.defaults import sbt.internal.CommandStrings.{ BootCommand, DefaultsCommand, InitCommand } + setSbtVersion(configuration.baseDirectory(), configuration.provider().id().version()) runManaged(initialState( configuration, Seq(defaults, early), runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil )) } + + private val sbtVersionRegex = """sbt\.version\s*=.*""".r + private def isSbtVersionLine(s: String) = sbtVersionRegex.pattern matcher s matches () + + private def isSbtProject(baseDir: File, projectDir: File) = + projectDir.exists() || (baseDir * "*.sbt").get.nonEmpty + + private def setSbtVersion(baseDir: File, sbtVersion: String) = { + val projectDir = baseDir / "project" + val buildProps = projectDir / "build.properties" + + val buildPropsLines = if (buildProps.canRead) IO.readLines(buildProps) else Nil + + val sbtVersionAbsent = buildPropsLines forall (!isSbtVersionLine(_)) + + if (sbtVersionAbsent) { + val errorMessage = s"WARN: No sbt.version set in project/build.properties, base directory: $baseDir" + try { + if (isSbtProject(baseDir, projectDir)) { + val newBuildPropsLines = s"sbt.version=$sbtVersion" :: buildPropsLines + IO.writeLines(buildProps, newBuildPropsLines) + } else + println(errorMessage) + } catch { + case _: IOException => println(errorMessage) + } + } + } } + final class ScriptMain extends xsbti.AppMain { def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = { diff --git a/notes/0.13.14.markdown b/notes/0.13.14.markdown new file mode 100644 index 000000000..10210419c --- /dev/null +++ b/notes/0.13.14.markdown @@ -0,0 +1,100 @@ +### Fixes with compatibility implications + +- sbt 0.13.14 removes the Maven version range when possible. See below. + +### Improvements + +- Adds preliminary compatibility with JDK 9. Using this requires 0.13.14+ launcher. [#2951][2951]/[143][143] by [@retronym][@retronym] +- Adds "local-preloaded" repository for offline installation. See below. +- Notifies and enables users to stay in sbt's shell on the warm JVM by hitting `[ENTER]` while sbt is running. [#2987][2987]/[#2996][2996] by [@dwijnand][@dwijnand] +- Adds an `Append` instance to support `sourceGenerators += Def.task { ... }`, instead of needing `.taskValue`. [#2943][2943] by [@eed3si9n][@eed3si9n] +- Writes out the sbt.version in project/build.properties if it is missing. [#754][]/[#3025][] by [@dwijnand][] +- XML generated by JUnitXmlTestsListener now correctly flags ignored, skipped and pending tests. [#2198][2198]/[#2854][2854] by [@ashleymercer][@ashleymercer] +- When sbt detects that the project is compiled with dotty, it now automatically + sets `scalaCompilerBridgeSource` correctly, this reduces the boilerplate needed + to make a dotty project. Note that dotty support in sbt is still considered + experimental and not officially supported, see [dotty.epfl.ch][dotty] for + more information. [#2902][2902] by [@smarter][@smarter] +- Updates sbt new's reference implementation to Giter8 0.7.2. + +### Bug fixes + +- Fixes .triggeredBy/.storeAs/etc not working when using `:=` and `.value` macros. [#1444][1444]/[#2908][2908] by [@dwijnand][@dwijnand] +- Fixes Ctrl-C not working on Windows by bumping up JLine. [#1855][1855] by [@eed3si9n][@eed3si9n] +- Fixes regressions in sbt 0.13.11 - 0.13.13 that processed build-level keys incorrectly. [#2851][2851]/[#2460][2460] by [@eed3si9n][@eed3si9n] +- Fixes a regression in sbt 0.13.12 that was misfiring Scala version enforcement when configuration does not extend `Compile`. [#2827][2827]/[#2786][2786] by [@eed3si9n][@eed3si9n] +- Fixes Scala binary version checking misfiring on configurations that do not extend `Compile`. [#2828][2828]/[#1466][1466] by [@eed3si9n][@eed3si9n] +- Fixes script mode ignoring quotation. [#2551][2551] by [@ekrich][@ekrich] +- Fixes IllegalStateException that Ivy gets into sometimes. [#2827][2827]/[#2015][2015] by [@eed3si9n][@eed3si9n] +- Fixes null sourceFile causing NPE. [#2766][2766] by [@avdv][@avdv] +- Fixes version parsing in validation. [#3011][3011] by [@eed3si9n][@eed3si9n] + +### Maven version range improvement + +Previously, when the dependency resolver (Ivy) encountered a Maven version range such as `[1.3.0,)` +it would go out to the Internet to find the latest version. +This would result to a surprising behavior where the eventual version keeps changing over time +*even when there's a version of the library that satisfies the range condition*. + +Starting sbt 0.13.14, some Maven version ranges would be replaced with its lower bound +so that when a satisfactory version is found in the dependency graph it will be used. +You can disable this behavior using the JVM flag `-Dsbt.modversionrange=false`. + +[#2954][2954] by [@eed3si9n][@eed3si9n] + +### Offline installation + +sbt 0.13.14 adds two new repositories called "local-preloaded-ivy" +and "local-preloaded" that point to `~/.sbt/preloaded/`. +The purpose for the repositories is to preload them with +sbt artifacts so the installation of sbt will not require access to the Internet. + +This also improves the startup time of sbt when you first run it +since the resolution happens off of a local-preloaded repository. + +[#2993][2993]/[#145][145] by [@eed3si9n][@eed3si9n] + +### Notes + +No changes should be necessary to your project definition and all plugins published for sbt 0.13.{x|x<14} should still work. + +See [Migrating from sbt 0.12.x](http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html) for details on the old operator deprecation. + +Special thanks to the contributors for making this release a success. According to `git shortlog -sn --no-merges v0.13.13..0.13`, compared to 0.13.13, there were 42 (non-merge) commits, by ten contributors: Dale Wijnand, Eugene Yokota, Guillaume Martres, Jason Zaugg, Petro Verkhogliad, Eric Richardson, Claudio Bley, Haochi Chen, Paul Draper, Ashley Mercer. Thank you! + + [143]: https://github.com/sbt/sbt-launcher-package/pull/143 + [145]: https://github.com/sbt/sbt-launcher-package/pull/145 + [754]: https://github.com/sbt/sbt/issues/754 + [2766]: https://github.com/sbt/sbt/issues/2766 + [1855]: https://github.com/sbt/sbt/issues/1855 + [1466]: https://github.com/sbt/sbt/issues/1466 + [2786]: https://github.com/sbt/sbt/issues/2786 + [2827]: https://github.com/sbt/sbt/pull/2827 + [2828]: https://github.com/sbt/sbt/pull/2828 + [2551]: https://github.com/sbt/sbt/issues/2551 + [2987]: https://github.com/sbt/sbt/issues/2987 + [2996]: https://github.com/sbt/sbt/pull/2996 + [2851]: https://github.com/sbt/sbt/issues/2851 + [2460]: https://github.com/sbt/sbt/issues/2460 + [2951]: https://github.com/sbt/sbt/pull/2951 + [2954]: https://github.com/sbt/sbt/issues/2954 + [2015]: https://github.com/sbt/sbt/issues/2015 + [2827]: https://github.com/sbt/sbt/pull/2827 + [2198]: https://github.com/sbt/sbt/issues/2198 + [2854]: https://github.com/sbt/sbt/pull/2854 + [1444]: https://github.com/sbt/sbt/issues/1444 + [2908]: https://github.com/sbt/sbt/pull/2908 + [2902]: https://github.com/sbt/sbt/pull/2902 + [2993]: https://github.com/sbt/sbt/pull/2993 + [2943]: https://github.com/sbt/sbt/pull/2943 + [3011]: https://github.com/sbt/sbt/issues/3011 + [3025]: https://github.com/sbt/sbt/issues/3025 + [@eed3si9n]: https://github.com/eed3si9n + [@dwijnand]: https://github.com/dwijnand + [@Duhemm]: https://github.com/Duhemm + [@avdv]: https://github.com/avdv + [@ekrich]: https://github.com/ekrich + [@retronym]: https://github.com/retronym + [@ashleymercer]: https://github.com/ashleymercer + [dotty]: http://dotty.epfl.ch/ + [@smarter]: https://github.com/smarter