From 15ecc9845a0a758e73ca97440a1dbc580d5e43d1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 16 Sep 2017 20:32:33 -0400 Subject: [PATCH 1/3] contributors --- notes/1.0.2.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notes/1.0.2.markdown b/notes/1.0.2.markdown index 44cad0df7..95b8de1f5 100644 --- a/notes/1.0.2.markdown +++ b/notes/1.0.2.markdown @@ -17,6 +17,12 @@ This is a hotfix release for sbt 1.0.x series. - Fixes unused import warnings. [#3533][3533] by [@razvan-panda][@razvan-panda] +### Contributors + +A huge thank you to everyone who's helped improve sbt and Zinc 1 by using them, reporting bugs, improving our documentation, porting plugins, and submitting and reviewing pull requests. + +This release was brought to you by 19 contributors, according to `git shortlog -sn --no-merges v1.0.1..v1.0.2` on sbt, zinc, librarymanagement, and website: Dale Wijnand, Eugene Yokota, Kenji Yoshida (xuwei-k), Antonio Cunei, David Pratt, Karol Cz (kczulko), Amanj Sherwany, Emanuele Blanco, Eric Peters, Guillaume Bort, James Roper, Joost de Vries, Marko Elezovic, Martynas Mickevičius, Michael Stringer, Răzvan Flavius Panda, Peter Vlugter, Philippus Baalman, and Wiesław Popielarski. Thank you! + [@dwijnand]: https://github.com/dwijnand [@cunei]: https://github.com/cunei [@eed3si9n]: https://github.com/eed3si9n From 45d69f37624193541837a169d7780dc7add96329 Mon Sep 17 00:00:00 2001 From: Justin Kaeser Date: Tue, 19 Sep 2017 19:04:28 +0200 Subject: [PATCH 2/3] Pass `allJars` when creating ScalaInstance instead of `otherJars`. Fixes https://github.com/sbt/sbt/issues/3560 required for https://youtrack.jetbrains.com/issue/SCL-12591 --- main/src/main/scala/sbt/Defaults.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 1936641bf..e63f8a05f 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -601,19 +601,18 @@ object Defaults extends BuildCommon { (art, file) <- m.artifacts if art.`type` == Artifact.DefaultType } yield file def file(id: String) = files(id).headOption getOrElse sys.error(s"Missing ${id}.jar") - val allFiles = toolReport.modules.flatMap(_.artifacts.map(_._2)) + val allJars = toolReport.modules.flatMap(_.artifacts.map(_._2)) val libraryJar = file(ScalaArtifacts.LibraryID) val binVersion = scalaBinaryVersion.value val compilerJar = if (ScalaInstance.isDotty(scalaVersion.value)) file(ScalaArtifacts.dottyID(binVersion)) else file(ScalaArtifacts.CompilerID) - val otherJars = allFiles.filterNot(x => x == libraryJar || x == compilerJar) new ScalaInstance(scalaVersion.value, - makeClassLoader(state.value)(libraryJar :: compilerJar :: otherJars.toList), + makeClassLoader(state.value)(allJars.toList), libraryJar, compilerJar, - otherJars.toArray, + allJars.toArray, None) } def scalaInstanceFromHome(dir: File): Initialize[Task[ScalaInstance]] = Def.task { From b9a4d329164d2306272d4af0470ec1a8a5aec14f Mon Sep 17 00:00:00 2001 From: Michael Stringer Date: Tue, 3 Oct 2017 10:30:06 +0100 Subject: [PATCH 3/3] Add system property to revert to old polling fs watcher This adds a sbt.watch.mode system property that if set to 'polling' will use PollingWatchService instead of WatchServiceAdapter (nio). On macOS this will default to 'polling' and on all others 'nio'. This is a temporary workaround for users affected by #3527 --- main-command/src/main/scala/sbt/Watched.scala | 29 ++++++++++++++----- main/src/main/scala/sbt/Defaults.scala | 3 +- notes/1.0.3/watch.md | 26 +++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 notes/1.0.3/watch.md diff --git a/main-command/src/main/scala/sbt/Watched.scala b/main-command/src/main/scala/sbt/Watched.scala index 08a1c5838..05754bb10 100644 --- a/main-command/src/main/scala/sbt/Watched.scala +++ b/main-command/src/main/scala/sbt/Watched.scala @@ -3,18 +3,19 @@ */ package sbt -import BasicCommandStrings.ClearOnFailure -import State.FailureWall -import annotation.tailrec import java.io.File import java.nio.file.FileSystems -import scala.concurrent.duration._ - -import sbt.io.{ AllPassFilter, NothingFilter, FileFilter, WatchService } +import sbt.BasicCommandStrings.ClearOnFailure +import sbt.State.FailureWall import sbt.internal.io.{ Source, SourceModificationWatch, WatchState } import sbt.internal.util.AttributeKey import sbt.internal.util.Types.const +import sbt.io._ + +import scala.annotation.tailrec +import scala.concurrent.duration._ +import scala.util.Properties trait Watched { @@ -35,7 +36,7 @@ trait Watched { private[sbt] def triggeredMessage(s: WatchState): String = Watched.defaultTriggeredMessage(s) /** The `WatchService` to use to monitor the file system. */ - private[sbt] def watchService(): WatchService = FileSystems.getDefault.newWatchService() + private[sbt] def watchService(): WatchService = Watched.createWatchService() } object Watched { @@ -121,4 +122,18 @@ object Watched { AttributeKey[WatchState]("watch state", "Internal: tracks state for continuous execution.") val Configuration = AttributeKey[Watched]("watched-configuration", "Configures continuous execution.") + + def createWatchService(): WatchService = { + sys.props.get("sbt.watch.mode") match { + case Some("polling") => + new PollingWatchService(PollDelay) + case Some("nio") => + FileSystems.getDefault.newWatchService() + case _ if Properties.isMac => + // WatchService is slow on macOS - use old polling mode + new PollingWatchService(PollDelay) + case _ => + FileSystems.getDefault.newWatchService() + } + } } diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index e63f8a05f..6664c4935 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -5,7 +5,6 @@ package sbt import Def.{ Initialize, ScopedKey, Setting, SettingsDefinition } import java.io.{ File, PrintWriter } -import java.nio.file.FileSystems import java.net.{ URI, URL } import java.util.Optional import java.util.concurrent.{ TimeUnit, Callable } @@ -246,7 +245,7 @@ object Defaults extends BuildCommon { parallelExecution :== true, pollInterval :== new FiniteDuration(500, TimeUnit.MILLISECONDS), watchService :== { () => - FileSystems.getDefault.newWatchService + Watched.createWatchService() }, logBuffered :== false, commands :== Nil, diff --git a/notes/1.0.3/watch.md b/notes/1.0.3/watch.md new file mode 100644 index 000000000..ff751fdf9 --- /dev/null +++ b/notes/1.0.3/watch.md @@ -0,0 +1,26 @@ +### Fixes with compatibility implications + +### Improvements + +- Add `sbt.watch.mode` system property to allow switching back to old polling behaviour for watch. See below for more details. [#3597][3597] by [@stringbean][@stringbean] + +### Bug fixes + +#### 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][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. + +[@stringbean]: https://github.com/stringbean +[3527]: https://github.com/sbt/sbt/issues/3527 +[3597]: https://github.com/sbt/sbt/pull/3597