Skip to content

[build-tools] Use environment variable to enable Gradle cache instead of gradle.properties#3849

Closed
sjchmiela wants to merge 2 commits into
mainfrom
stanley/inspect-slack-thread
Closed

[build-tools] Use environment variable to enable Gradle cache instead of gradle.properties#3849
sjchmiela wants to merge 2 commits into
mainfrom
stanley/inspect-slack-thread

Conversation

@sjchmiela

@sjchmiela sjchmiela commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@sjchmiela sjchmiela changed the title Return Gradle cache env from restore helpers and log it in consumers [build-tools] Use environment variable to enable Gradle cache instead of gradle.properties Jun 11, 2026
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.25000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.28%. Comparing base (1431a20) to head (4f5bdcf).

Files with missing lines Patch % Lines
...ild-tools/src/steps/functions/restoreBuildCache.ts 8.34% 10 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3849      +/-   ##
==========================================
+ Coverage   58.27%   58.28%   +0.02%     
==========================================
  Files         917      917              
  Lines       39840    39848       +8     
  Branches     8384     8359      -25     
==========================================
+ Hits        23212    23222      +10     
+ Misses      16533    15191    -1342     
- Partials       95     1435    +1340     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sjchmiela sjchmiela added the no changelog PR that doesn't require a changelog entry label Jun 11, 2026
@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

@sjchmiela sjchmiela marked this pull request as ready for review June 11, 2026 11:35
@sjchmiela sjchmiela requested review from AbbanMustafa and Copilot and removed request for AbbanMustafa June 11, 2026 11:35
@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Android Gradle build-cache enablement in @expo/build-tools to avoid mutating android/gradle.properties (which can affect fingerprinting) and instead enables caching via environment variables that are propagated into the Gradle invocation.

Changes:

  • Change restoreGradleCacheAsync to return Gradle-cache-related environment variables (instead of editing android/gradle.properties).
  • Plumb returned env vars into both the workflow step (createRestoreBuildCacheFunction) and the Android builder restore-cache phase (androidBuilder).
  • Add logging (and a unit test) to confirm the returned env vars are surfaced when present.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/build-tools/src/steps/functions/restoreBuildCache.ts Return Gradle cache env vars from cache restore and update workflow global env; add helper to log env vars.
packages/build-tools/src/builders/android.ts Apply returned Gradle cache env vars to the builder’s runtime environment and log them.
packages/build-tools/src/builders/tests/android.test.ts Update mocks and add coverage for logging Gradle cache env vars returned by restoreGradleCacheAsync.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

`${gradlePropertiesContent}\n\norg.gradle.caching=true\n`
);
const gradleCacheEnv = {
'ORG_GRADLE_PROJECT_org.gradle.caching': 'true',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely certain this will truly enable the property still. ref gradle/gradle#18087

I will validate your branch locally to see

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this locally and validated it does not enable gradle caching. In restore

Restoring Gradle cache key: android-gradle-cache-f0ece61fb139c94a5b03cfd08ced7227a2d238dc293484d692233893e90d8752
Matched cache key: android-gradle-cache-f0ece61fb139c94a5b03cfd08ced7227a2d238dc293484d692233893e90d8752. Downloading...
Gradle cache restored to /Users/mustafa/.gradle/caches (direct hit)
Enabling Gradle cache. Running Gradle with additional environment variables.
ORG_GRADLE_PROJECT_org.gradle.caching=true

in run gradle

[EAS] Gradle build cache entries before cleanup: 464
[EAS] Configured Gradle cache cleanup via init script
...

[EAS] Gradle build cache entries after build: 464 (was 464)

what I expected to see and what I saw with current setup

[EAS] Gradle build cache entries after build: 476 (was 464)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah but we can modify ~/.gradle/gradle.properties and leave the project untouched

@sjchmiela

Copy link
Copy Markdown
Contributor Author

superseded by #3852

@sjchmiela sjchmiela closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants