Backport #1097/#1098 to v5: cache Maven and Gradle wrapper distributions separately#1122
Merged
Merged
Conversation
…parately Backports the wrapper caching fix to the v5 release line. The Maven wrapper distribution (~/.m2/wrapper/dists) and Gradle wrapper distribution (~/.gradle/wrapper) were cached in the same entry as the dependency cache, keyed on the volatile dependency-file hashes (**/pom.xml, **/*.gradle*). With no restoreKeys fallback (#269), almost every dependency change was a full cache miss, forcing ./mvnw and ./gradlew to re-download the build tool distribution and hitting intermittent rate-limit failures. Each wrapper distribution now lives in its own additional cache entry keyed only on the rarely-changing wrapper properties file (**/.mvn/wrapper/maven-wrapper.properties, **/gradle-wrapper.properties), so it survives dependency changes. Optional-cache saves swallow ValidationError and ReserveCacheError so a project without a wrapper never fails the post step. Fixes: #1095 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea015caa-980a-4e0a-af20-3fc9f39c77fd
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.
Description
Backports the wrapper caching fix (#1097 for Maven, #1098 for Gradle) to the v5 release line, so the majority of users who pin
actions/setup-java@v5get the reliability improvement without waiting for the next major (mainis already at6.0.0).Why
The Maven wrapper distribution (
~/.m2/wrapper/dists) and Gradle wrapper distribution (~/.gradle/wrapper) were cached in the same entry as the dependency cache, keyed on the volatile dependency-file hashes (**/pom.xml,**/*.gradle*). Since those files change constantly and there are intentionally norestoreKeysfallbacks (#269), nearly every dependency change was a full cache miss, forcing./mvnw/./gradlewto re-download the build tool distribution and hitting the intermittent rate-limit failures reported in #1095.Approach
Each wrapper distribution now lives in its own additional cache entry keyed only on the rarely-changing wrapper properties file:
~/.m2/wrapper/distskeyed on**/.mvn/wrapper/maven-wrapper.properties~/.gradle/wrapperkeyed on**/gradle-wrapper.propertiesso the distribution survives the frequent dependency-file changes that rotate the main cache key. Optional-cache saves swallow
ValidationErrorandReserveCacheError, so a project without a wrapper never fails the post step. Main-cache outputs (cache-hit,cache-primary-key) are unchanged for backward compatibility.Notes for reviewers
src/cache.ts,__tests__/cache.test.ts, the README caching notes, and the rebuiltdist/. Thedocs/advanced-usage.mdchanges frommainwere intentionally omitted because they anchor to a caching-completeness section that does not exist on the v5 branch.jest.spyOn+STATE_*-backedgetState), which differs frommain.format-checkandlintare clean;dist/rebuilt.Fixes: #1095