Skip to content

Enable Gradle build, parallel, and configuration caches for Android#341

Merged
dkhalife merged 1 commit into
mainfrom
dkhalife/gradle-build-cache
Jun 6, 2026
Merged

Enable Gradle build, parallel, and configuration caches for Android#341
dkhalife merged 1 commit into
mainfrom
dkhalife/gradle-build-cache

Conversation

@dkhalife

@dkhalife dkhalife commented Jun 6, 2026

Copy link
Copy Markdown
Owner

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:

org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true

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-cache speed up every build.

Configuration-cache compatibility fix

Initial validation (./gradlew help --configuration-cache) failed with one problem: resolveGitSha() in app/build.gradle.kts started an external git rev-parse HEAD process 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.exec API (and removed the now-unused ByteArrayOutputStream import). This keeps all three flags enabled with no behavior change to the embedded GIT_SHA.

Build result

  • ./gradlew help --configuration-cacheBUILD SUCCESSFUL, configuration cache entry stored.
  • ./gradlew :app:assembleDebug --configuration-cacheBUILD 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.

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.
Copilot AI review requested due to automatic review settings June 6, 2026 19:27
@dkhalife dkhalife merged commit d125c4a into main Jun 6, 2026
7 checks passed
@dkhalife dkhalife deleted the dkhalife/gradle-build-cache branch June 6, 2026 19:29

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 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, and org.gradle.configuration-cache in android/gradle.properties.
  • Migrated resolveGitSha() to providers.exec and removed the now-unused ByteArrayOutputStream import.
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 thread android/gradle.properties
Comment on lines +5 to +7
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true
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.

2 participants