diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 4b6e11db9..68882c9dc 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -154,15 +154,11 @@ object Defaults extends BuildCommon { inputFileStamper :== sbt.nio.FileStamper.Hash, outputFileStamper :== sbt.nio.FileStamper.LastModified, onChangedBuildSource :== sbt.nio.Keys.WarnOnSourceChanges, - watchTriggeredMessage :== sbt.nio.Watch.defaultOnTriggerMessage, - watchForceTriggerOnAnyChange :== false, - watchPersistFileStamps :== true, - watchTriggers :== Nil, clean := { () }, unmanagedFileStampCache := state.value.get(persistentFileStampCache).getOrElse(new sbt.nio.FileStamp.Cache), managedFileStampCache := new sbt.nio.FileStamp.Cache, - ) ++ globalIvyCore ++ globalJvmCore + ) ++ globalIvyCore ++ globalJvmCore ++ Watch.defaults ) ++ globalSbtCore private[sbt] lazy val globalJvmCore: Seq[Setting[_]] = @@ -344,17 +340,6 @@ object Defaults extends BuildCommon { sys.env.contains("CI") || System.getProperty("sbt.ci", "false") == "true", // watch related settings pollInterval :== Watch.defaultPollInterval, - watchAntiEntropy :== Watch.defaultAntiEntropy, - watchAntiEntropyRetentionPeriod :== Watch.defaultAntiEntropyRetentionPeriod, - watchLogLevel :== Level.Info, - watchOnEnter :== Watch.defaultOnEnter, - watchOnFileInputEvent :== Watch.trigger, - watchDeletionQuarantinePeriod :== Watch.defaultDeletionQuarantinePeriod, - watchService :== Watched.newWatchService, - watchStartMessage :== Watch.defaultStartWatch, - watchTasks := Continuous.continuousTask.evaluated, - aggregate in watchTasks :== false, - watchTriggeredMessage :== Watch.defaultOnTriggerMessage, ) ) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 0057dd087..de3266bee 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -125,7 +125,6 @@ object Keys { val managedSources = taskKey[Seq[File]]("Sources generated by the build.").withRank(BTask) val sources = taskKey[Seq[File]]("All sources, both managed and unmanaged.").withRank(BTask) val sourcesInBase = settingKey[Boolean]("If true, sources from the project's base directory are included as main sources.") - val watchTriggers = settingKey[Seq[Glob]]("Describes files that should trigger a new continuous build.") // Filters val includeFilter = settingKey[FileFilter]("Filter for including sources and resources files from default directories.").withRank(CSetting) diff --git a/main/src/main/scala/sbt/ScriptedPlugin.scala b/main/src/main/scala/sbt/ScriptedPlugin.scala index 2bc1b13fe..113fdd114 100644 --- a/main/src/main/scala/sbt/ScriptedPlugin.scala +++ b/main/src/main/scala/sbt/ScriptedPlugin.scala @@ -12,6 +12,7 @@ import java.lang.reflect.Method import sbt.Def._ import sbt.Keys._ +import sbt.nio.Keys._ import sbt.Project._ import sbt.internal.inc.ModuleUtilities import sbt.internal.inc.classpath.ClasspathUtilities diff --git a/main/src/main/scala/sbt/nio/Keys.scala b/main/src/main/scala/sbt/nio/Keys.scala index 9d2702a96..7632e04cc 100644 --- a/main/src/main/scala/sbt/nio/Keys.scala +++ b/main/src/main/scala/sbt/nio/Keys.scala @@ -108,6 +108,8 @@ object Keys { "watch", "Watch a task (or multiple tasks) and rebuild when its file inputs change or user input is received. The semantics are more or less the same as the `~` command except that it cannot transform the state on exit. This means that it cannot be used to reload the build." ).withRank(DSetting) + val watchTriggers = + settingKey[Seq[Glob]]("Describes files that should trigger a new continuous build.") val watchTriggeredMessage = settingKey[(Int, Path, Seq[String]) => Option[String]]( "The message to show before triggered execution executes an action after sources change. The parameters are the path that triggered the build and the current watch iteration count." ).withRank(DSetting) diff --git a/main/src/main/scala/sbt/nio/Watch.scala b/main/src/main/scala/sbt/nio/Watch.scala index 5eb4cf344..745af45a1 100644 --- a/main/src/main/scala/sbt/nio/Watch.scala +++ b/main/src/main/scala/sbt/nio/Watch.scala @@ -15,10 +15,12 @@ import java.util.concurrent.TimeUnit import sbt.BasicCommandStrings.ContinuousExecutePrefix import sbt._ +import sbt.internal.Continuous import sbt.internal.LabeledFunctions._ import sbt.internal.nio.FileEvent import sbt.internal.util.complete.Parser import sbt.internal.util.complete.Parser._ +import sbt.nio.Keys._ import sbt.nio.file.FileAttributes import sbt.util.{ Level, Logger } @@ -476,4 +478,20 @@ object Watch { */ final val clearOnTrigger: Int => Option[String] = ((_: Int) => Some(Watched.clearScreen)).label("Watched.clearOnTrigger") + private[sbt] def defaults: Seq[Def.Setting[_]] = Seq( + sbt.Keys.watchAntiEntropy :== Watch.defaultAntiEntropy, + watchAntiEntropyRetentionPeriod :== Watch.defaultAntiEntropyRetentionPeriod, + watchLogLevel :== Level.Info, + watchOnEnter :== Watch.defaultOnEnter, + watchOnFileInputEvent :== Watch.trigger, + watchDeletionQuarantinePeriod :== Watch.defaultDeletionQuarantinePeriod, + sbt.Keys.watchService :== Watched.newWatchService, + watchStartMessage :== Watch.defaultStartWatch, + watchTasks := Continuous.continuousTask.evaluated, + sbt.Keys.aggregate in watchTasks :== false, + watchTriggeredMessage :== Watch.defaultOnTriggerMessage, + watchForceTriggerOnAnyChange :== false, + watchPersistFileStamps :== true, + watchTriggers :== Nil, + ) }