Enable Gradle build, parallel, and configuration caches for Android#341
Merged
Conversation
Adds org.gradle.caching, org.gradle.parallel, and org.gradle.configuration-cache to android/gradle.properties to speed up builds and enable compiled-output reuse across worktrees via the shared local build cache in GRADLE_USER_HOME. The configuration cache flagged resolveGitSha() in app/build.gradle.kts for starting an external 'git rev-parse HEAD' process at configuration time. Migrated it to the configuration-cache-compatible providers.exec API so all three flags can stay enabled.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables Gradle build optimizations for the Android project by turning on the build cache, parallel execution, and configuration cache, and updates the build script to use a configuration-cache-compatible API for resolving the git SHA.
Changes:
- Enabled
org.gradle.caching,org.gradle.parallel, andorg.gradle.configuration-cacheinandroid/gradle.properties. - Migrated
resolveGitSha()toproviders.execand removed the now-unusedByteArrayOutputStreamimport.
Show a summary per file
| File | Description |
|---|---|
| android/gradle.properties | Enables Gradle caches and parallelism to speed up Android builds. |
| android/app/build.gradle.kts | Adjusts git SHA resolution to be compatible with configuration cache constraints. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
Comment on lines
33
to
+37
| return try { | ||
| val output = ByteArrayOutputStream() | ||
| exec { | ||
| providers.exec { | ||
| commandLine("git", "rev-parse", "HEAD") | ||
| standardOutput = output | ||
| isIgnoreExitValue = true | ||
| } | ||
| output.toString().trim().ifBlank { "local" } | ||
| }.standardOutput.asText.get().trim().ifBlank { "local" } |
Comment on lines
+5
to
+7
| org.gradle.caching=true | ||
| org.gradle.parallel=true | ||
| org.gradle.configuration-cache=true |
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
Enables Gradle's built-in caches for the Android project (
android/) to speed up builds and allow compiled-output reuse across git worktrees. Config-only change plus one small build-script compatibility fix.Flags kept (all three)
Added to
android/gradle.properties:The local build cache lives in the shared
GRADLE_USER_HOME(~/.gradle), so identical tasks compiled in one worktree are reused in another.parallel+configuration-cachespeed up every build.Configuration-cache compatibility fix
Initial validation (
./gradlew help --configuration-cache) failed with one problem:resolveGitSha()inapp/build.gradle.ktsstarted an externalgit rev-parse HEADprocess at configuration time, which the configuration cache forbids.This was trivially resolvable, so rather than dropping the flag I migrated it to the configuration-cache-compatible
providers.execAPI (and removed the now-unusedByteArrayOutputStreamimport). This keeps all three flags enabled with no behavior change to the embeddedGIT_SHA.Build result
./gradlew help --configuration-cache→ BUILD SUCCESSFUL, configuration cache entry stored../gradlew :app:assembleDebug --configuration-cache→ BUILD SUCCESSFUL, debug APK assembled, configuration cache entry stored.(One transient "Could not connect to Kotlin compile daemon" message appeared during assembly; Gradle automatically fell back to in-process compilation and the build completed successfully. It is environmental and unrelated to these flags.)
No frontend or Go apiserver changes; no bespoke scripts added.