Skip to content

Cache Gradle wrapper distribution separately from the dependency cache#1098

Merged
brunoborges merged 1 commit into
brunoborges-fix-maven-wrapper-cachingfrom
brunoborges-cache-gradle-wrapper-separately
Jul 10, 2026
Merged

Cache Gradle wrapper distribution separately from the dependency cache#1098
brunoborges merged 1 commit into
brunoborges-fix-maven-wrapper-cachingfrom
brunoborges-cache-gradle-wrapper-separately

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Description:
The Gradle wrapper distribution (~/.gradle/wrapper) is downloaded by gradlew and depends only on gradle/wrapper/gradle-wrapper.properties, which changes very rarely. However, it was previously stored in the same cache entry as the Gradle dependency caches (~/.gradle/caches), whose key is computed from volatile files such as **/*.gradle*. Because there are intentionally no restoreKeys (see #269), almost every dependency change is a full cache miss, so the rarely-changing wrapper distribution was re-downloaded on every build.

This is the same root cause fixed for the Maven wrapper in #1097. This PR applies the identical treatment to Gradle:

  • Move ~/.gradle/wrapper out of the main Gradle cache path (leaving ~/.gradle/caches).
  • Add a dedicated gradle-wrapper additional cache keyed only on **/gradle-wrapper.properties.

This keeps the wrapper distribution cached across the frequent **/*.gradle* changes that rotate the main cache key. The main Gradle cache key computation is unchanged (its pattern still lists **/gradle-wrapper.properties, among others).

This is a stacked follow-up to #1097 and depends on the generic additionalCaches infrastructure introduced there (AdditionalCache interface, computeAdditionalCacheKey, restoreAdditionalCache, saveAdditionalCache, and name-scoped restore→save state keys). It reuses that infrastructure without modifying Maven or sbt.

Related issue:
Related context: #1095 (the closing Fixes #1095 reference belongs to #1097).

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

The Gradle wrapper distribution (~/.gradle/wrapper) only depends on
gradle-wrapper.properties, which changes rarely, but it was previously
cached in the same entry as ~/.gradle/caches, keyed on volatile
**/*.gradle* files with no restoreKeys (issue #269). Every dependency
change therefore re-downloaded the wrapper.

Move ~/.gradle/wrapper into a dedicated `gradle-wrapper` additional
cache keyed only on **/gradle-wrapper.properties, reusing the
additionalCaches infrastructure introduced for the Maven wrapper fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@brunoborges brunoborges requested a review from a team as a code owner July 10, 2026 00:37
@brunoborges brunoborges merged commit ac3a4a8 into brunoborges-fix-maven-wrapper-caching Jul 10, 2026
403 checks passed
@brunoborges brunoborges deleted the brunoborges-cache-gradle-wrapper-separately branch July 10, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant