Merge pull request #6099 from xirc/system-property-for-on-changed-build-source

Support a system property for onChangedBuildSource
This commit is contained in:
eugene yokota 2020-11-17 08:53:38 -05:00 committed by GitHub
commit c52e9916e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -167,7 +167,7 @@ object Defaults extends BuildCommon {
fileOutputExcludeFilter :== NothingFilter.toNio,
inputFileStamper :== sbt.nio.FileStamper.Hash,
outputFileStamper :== sbt.nio.FileStamper.LastModified,
onChangedBuildSource :== sbt.nio.Keys.WarnOnSourceChanges,
onChangedBuildSource :== SysProp.onChangedBuildSource,
clean := { () },
unmanagedFileStampCache :=
state.value.get(persistentFileStampCache).getOrElse(new sbt.nio.FileStamp.Cache),

View File

@ -14,6 +14,7 @@ import scala.util.control.NonFatal
import scala.concurrent.duration._
import sbt.internal.util.{ Terminal => ITerminal }
import sbt.internal.util.complete.SizeParser
import sbt.nio.Keys._
// See also BuildPaths.scala
// See also LineReader.scala
@ -162,4 +163,17 @@ object SysProp {
case None => true
}
}
def onChangedBuildSource: WatchBuildSourceOption = {
val sysPropKey = "sbt.build.onchange"
sys.props.getOrElse(sysPropKey, "warn") match {
case "reload" => ReloadOnSourceChanges
case "warn" => WarnOnSourceChanges
case "ignore" => IgnoreSourceChanges
case unknown =>
System.err.println(s"Unknown $sysPropKey: $unknown.\nUsing warn.")
sbt.nio.Keys.WarnOnSourceChanges
}
}
}