[1.x] fix: Invalidate update cache across commands when dependencies change#8593
Merged
eed3si9n merged 2 commits intosbt:1.12.xfrom Jan 20, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of #8501 to 1.x: Fix update cache invalidation across sbt command invocations when a dependency's dependencies change.
Problem
When project A's dependencies changed and A was compiled in one command, project B (depending on A) would not invalidate its update cache in a subsequent command. This caused stale classpaths.
The root cause was that
depsUpdatedonly checked!stats.cached, which only detected fresh resolves within the same command. When a dependency was served from cache (even if resolved fresh in a previous command),cachedwas markedtruebymarkAsCached, causing incorrect cache reuse.Debug scenario from issue:
sbt:aaa> clean
sbt:aaa> a/compile
sbt:aaa> show itTests/depsUpdated
[info] * false <-- BUG: should be true
Solution
Instead of relying on the transient
cachedflag, we now hash the resolved module IDs (organization, name, revision) from each transitive dependency and include these hashes in the cache key (UpdateInputs).Note: Unlike 2.x which adds a
stampfield toUpdateStatsin librarymanagement, this 1.x backport achieves the same goal without requiring changes to the external librarymanagement library.Changes
UpdateInputstype to includeVector[Long]for transitive dependency hashesdepsUpdated: Booleanparameter totransitiveUpdates: Seq[UpdateReport]!depsUpdatedcheck fromupToDate(now covered by input hash)i8357-transitive-update-invalidationTest plan
scripted dependency-management/i8357-transitive-update-invalidationFixes #8357
Ref #8592