[2.x] Fix watchTriggers to control what triggers instead of adding to fileInputs (#8525)

When watchTriggers is explicitly set (non-empty), use only watchTriggers
instead of combining them with fileInputs. This allows users to control
what triggers the watch by setting watchTriggers.

Fixes #7130
This commit is contained in:
SID 2026-01-13 18:14:10 -08:00 committed by GitHub
parent 43e0428bed
commit 0c6b4c9741
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -135,7 +135,14 @@ private[sbt] object WatchTransitiveDependencies {
triggers.flatMap(getDynamicInputs(_, trigger = true))
)
}
(inputGlobs ++ triggerGlobs ++ legacy(keys :+ scopedKey, args)).distinct.sorted
// If watchTriggers is explicitly set (non-empty), use only watchTriggers instead of combining with fileInputs
// This allows users to control what triggers the watch by setting watchTriggers
val result = if (triggerGlobs.nonEmpty) {
triggerGlobs ++ legacy(keys :+ scopedKey, args)
} else {
inputGlobs ++ triggerGlobs ++ legacy(keys :+ scopedKey, args)
}
result.distinct.sorted
}
private def legacy(keys: Seq[ScopedKey[?]], args: Arguments): Seq[DynamicInput] = {