From fff32db7ceca4f933dc9a903da76ede4598a468e Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 28 Mar 2018 17:09:12 -0700 Subject: [PATCH 1/2] Use MacOSXWatchService instead of PollingWatchService This watch service should be more responsive and significantly reduce the disk overhead of the polling based service for large repos. --- main-command/src/main/scala/sbt/Watched.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main-command/src/main/scala/sbt/Watched.scala b/main-command/src/main/scala/sbt/Watched.scala index 8b8385b61..1c2396593 100644 --- a/main-command/src/main/scala/sbt/Watched.scala +++ b/main-command/src/main/scala/sbt/Watched.scala @@ -141,7 +141,7 @@ object Watched { FileSystems.getDefault.newWatchService() case _ if Properties.isMac => // WatchService is slow on macOS - use old polling mode - new PollingWatchService(PollDelay) + new MacOSXWatchService(PollDelay) case _ => FileSystems.getDefault.newWatchService() } From 707bf08c4e46faadce3adbbc8ab4514e3ba5bf4b Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Apr 2018 20:29:26 -0400 Subject: [PATCH 2/2] Add new closewatch mode --- main-command/src/main/scala/sbt/Watched.scala | 6 +++--- project/Dependencies.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main-command/src/main/scala/sbt/Watched.scala b/main-command/src/main/scala/sbt/Watched.scala index 1c2396593..cff9c1597 100644 --- a/main-command/src/main/scala/sbt/Watched.scala +++ b/main-command/src/main/scala/sbt/Watched.scala @@ -134,14 +134,14 @@ object Watched { AttributeKey[Watched]("watched-configuration", "Configures continuous execution.") def createWatchService(): WatchService = { + def closeWatch = new MacOSXWatchService() 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 MacOSXWatchService(PollDelay) + case Some("closewatch") => closeWatch + case _ if Properties.isMac => closeWatch case _ => FileSystems.getDefault.newWatchService() } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 94a583ea8..88d72b833 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,7 +8,7 @@ object Dependencies { val baseScalaVersion = scala212 // sbt modules - private val ioVersion = "1.1.4" + private val ioVersion = "1.1.5" private val utilVersion = "1.1.3" private val lmVersion = "1.1.4" private val zincVersion = "1.1.3"