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".
This commit is contained in:
Ethan Atkins 2018-10-09 21:47:57 -07:00
parent dc4f705500
commit 0a9ae7b4b4
1 changed files with 8 additions and 1 deletions

View File

@ -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)