From 0a9ae7b4b49da95bcac27db8dace663b54ff7686 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 9 Oct 2018 21:47:57 -0700 Subject: [PATCH] Use FileTreeRepository when interactive or continuous Ideally we use the FileTreeRepository for interactive sessions by default. A continuous build is effectively interactive, so I'd like that case to also use the file tree repository. To avoid breaking scripted tests, many of which implicitly expect file tree changes to be instantaneously available, we set interactive to true only if we are not in a scripted run, which can be verified by checking that the commands contains "setUpScripted". --- main/src/main/scala/sbt/internal/FileManagement.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/internal/FileManagement.scala b/main/src/main/scala/sbt/internal/FileManagement.scala index 127fd4a1d..15a17461a 100644 --- a/main/src/main/scala/sbt/internal/FileManagement.scala +++ b/main/src/main/scala/sbt/internal/FileManagement.scala @@ -15,10 +15,17 @@ import sbt.io.FileTreeDataView.Entry import sbt.io.syntax.File import sbt.io.{ FileFilter, FileTreeDataView, FileTreeRepository } import sbt._ +import BasicCommandStrings.ContinuousExecutePrefix private[sbt] object FileManagement { private[sbt] def defaultFileTreeView: Def.Initialize[Task[FileTreeViewConfig]] = Def.task { - if (state.value.remainingCommands.exists(_.commandLine == "shell")) { + val remaining = state.value.remainingCommands.map(_.commandLine.trim) + // If the session is interactive or if the commands include a continuous build, then use + // the default configuration. Otherwise, use the sbt1_2_compat config, which does not cache + // anything, which makes it less likely to cause issues with CI. + val interactive = remaining.contains("shell") && !remaining.contains("setUpScripted") + val continuous = remaining.exists(_.startsWith(ContinuousExecutePrefix)) + if (interactive || continuous) { FileTreeViewConfig .default(watchAntiEntropy.value, pollInterval.value, pollingDirectories.value) } else FileTreeViewConfig.sbt1_2_compat(pollInterval.value, watchAntiEntropy.value)