[build-tools] Use environment variable to enable Gradle cache instead of gradle.properties#3849
[build-tools] Use environment variable to enable Gradle cache instead of gradle.properties#3849sjchmiela wants to merge 2 commits into
gradle.properties#3849Conversation
gradle.properties
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
⏩ The changelog entry check has been skipped since the "no changelog" label is present. |
|
Subscribed to pull request
Generated by CodeMention |
There was a problem hiding this comment.
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
restoreGradleCacheAsyncto return Gradle-cache-related environment variables (instead of editingandroid/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', |
There was a problem hiding this comment.
I'm not entirely certain this will truly enable the property still. ref gradle/gradle#18087
I will validate your branch locally to see
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
ah but we can modify ~/.gradle/gradle.properties and leave the project untouched
|
superseded by #3852 |
Instead of mutating
gradle.propertieswhich can influence fingerprint we can use environment variable to enable caching.See https://docs.gradle.org/current/userguide/build_environment.html#setting_a_project_property and https://exponent-internal.slack.com/archives/C1QP38NQ5/p1781167813244859?thread_ts=1781160178.382929&cid=C1QP38NQ5.