[2.x] fix: Fixes pollInterval (#9020)

**Problem/Solution**
checkBuildSources / pollInterval should just fallback to some value.
This commit is contained in:
eugene yokota 2026-04-05 00:52:29 -04:00 committed by GitHub
parent ed49601662
commit 90770b6ad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -418,6 +418,7 @@ object Defaults extends BuildCommon with DefExtra {
terminal := Def.uncached(state.value.get(terminalKey).getOrElse(Terminal(ITerminal.get))), terminal := Def.uncached(state.value.get(terminalKey).getOrElse(Terminal(ITerminal.get))),
InstallSbtn.installSbtn := InstallSbtn.installSbtnImpl.evaluated, InstallSbtn.installSbtn := InstallSbtn.installSbtnImpl.evaluated,
InstallSbtn.installSbtn / aggregate := false, InstallSbtn.installSbtn / aggregate := false,
checkBuildSources / pollInterval :== CheckBuildSources.defaultPollInterval,
) ++ LintUnused.lintSettings ) ++ LintUnused.lintSettings
++ DefaultBackgroundJobService.backgroundJobServiceSettings ++ DefaultBackgroundJobService.backgroundJobServiceSettings
++ RemoteCache.globalSettings ++ RemoteCache.globalSettings
@ -553,8 +554,6 @@ object Defaults extends BuildCommon with DefExtra {
sourceManaged := target.value / "src_managed", sourceManaged := target.value / "src_managed",
resourceManaged := target.value / "resource_managed", resourceManaged := target.value / "resource_managed",
// Adds subproject build.sbt files to the global list of build files to monitor // Adds subproject build.sbt files to the global list of build files to monitor
Scope.Global / checkBuildSources / pollInterval :==
new FiniteDuration(Int.MinValue, TimeUnit.MILLISECONDS),
Scope.Global / checkBuildSources / fileInputs ++= { Scope.Global / checkBuildSources / fileInputs ++= {
if ((Scope.Global / onChangedBuildSource).value != IgnoreSourceChanges) if ((Scope.Global / onChangedBuildSource).value != IgnoreSourceChanges)
Seq(baseDirectory.value.toGlob / "*.sbt") Seq(baseDirectory.value.toGlob / "*.sbt")
@ -3387,7 +3386,7 @@ object Classpaths {
maybeUpdateRemoteProjects := Def.uncached(Def.taskDyn { maybeUpdateRemoteProjects := Def.uncached(Def.taskDyn {
val buildDeps = buildDependencies.value val buildDeps = buildDependencies.value
val thisRef = thisProjectRef.value val thisRef = thisProjectRef.value
val lb = Project.extract(state.value).get(Keys.loadedBuild) val lb = loadedBuild.value
val vcsRootRefs = Resolvers.transitiveVcsRootRefs(thisRef, buildDeps, lb) val vcsRootRefs = Resolvers.transitiveVcsRootRefs(thisRef, buildDeps, lb)
if (vcsRootRefs.isEmpty) Def.task(()) if (vcsRootRefs.isEmpty) Def.task(())
else Def.sequential(vcsRootRefs.map(_ / fetchSource).toSeq) else Def.sequential(vcsRootRefs.map(_ / fetchSource).toSeq)

View File

@ -10,6 +10,7 @@ package sbt
package internal.nio package internal.nio
import java.nio.file.Path import java.nio.file.Path
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference } import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference }
import sbt.BasicCommandStrings.{ RebootCommand, Shutdown, TerminateAction } import sbt.BasicCommandStrings.{ RebootCommand, Shutdown, TerminateAction }
import sbt.Keys.{ baseDirectory, pollInterval, state } import sbt.Keys.{ baseDirectory, pollInterval, state }
@ -65,7 +66,9 @@ private[sbt] class CheckBuildSources extends AutoCloseable {
} }
private def reset(state: State): Unit = { private def reset(state: State): Unit = {
val extracted = Project.extract(state) val extracted = Project.extract(state)
val interval = extracted.get(checkBuildSources / pollInterval) val interval = extracted
.getOpt(checkBuildSources / pollInterval)
.getOrElse(CheckBuildSources.defaultPollInterval)
val newSources = extracted.get(Global / checkBuildSources / fileInputs).distinct val newSources = extracted.get(Global / checkBuildSources / fileInputs).distinct
if (interval >= 0.seconds || "polling" == SysProp.watchMode) { if (interval >= 0.seconds || "polling" == SysProp.watchMode) {
Option(repository.getAndSet(null)).foreach(_.close()) Option(repository.getAndSet(null)).foreach(_.close())
@ -174,7 +177,9 @@ private[sbt] class CheckBuildSources extends AutoCloseable {
override def close(): Unit = {} override def close(): Unit = {}
} }
private[sbt] object CheckBuildSources { private[sbt] object CheckBuildSources:
val defaultPollInterval: FiniteDuration = FiniteDuration(Int.MinValue, TimeUnit.MILLISECONDS)
private[sbt] val CheckBuildSourcesKey = private[sbt] val CheckBuildSourcesKey =
AttributeKey[CheckBuildSources]("check-build-source", "", KeyRanks.Invisible) AttributeKey[CheckBuildSources]("check-build-source", "", KeyRanks.Invisible)
/* /*
@ -219,4 +224,4 @@ private[sbt] object CheckBuildSources {
projectGlobs(projectDir, baseDir.toGlob / "*.sbt" :: Nil) projectGlobs(projectDir, baseDir.toGlob / "*.sbt" :: Nil)
} else Nil } else Nil
} }
} end CheckBuildSources