Skip to content

Commit 8f93856

Browse files
authored
Merge pull request #357 from hossain-khan/copilot/optimize-ci-build-time
Optimize Gradle build performance with advanced configuration
2 parents c7049bb + 44f7b18 commit 8f93856

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,9 @@ metro {
238238
}
239239

240240

241-
// Helper function to get the current Git commit hash
241+
// Helper function to get the current Git commit hash (configuration cache compatible)
242242
fun getGitCommitHash(): String {
243-
val processBuilder = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
244-
val output = File.createTempFile("git-short-commit-hash", "")
245-
processBuilder.redirectOutput(output)
246-
val process = processBuilder.start()
247-
process.waitFor()
248-
return output.readText().trim()
243+
return providers.exec {
244+
commandLine("git", "rev-parse", "--short", "HEAD")
245+
}.standardOutput.asText.get().trim()
249246
}

gradle.properties

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9-
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
9+
# Reference: https://github.com/android/nowinandroid/blob/main/gradle.properties
10+
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx4g
1011

11-
# When configured, Gradle will run in incubating parallel mode.
12-
# This option should only be used with decoupled projects. For more details, visit
12+
# Kotlin Daemon arguments with optimized GC settings
13+
kotlin.daemon.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=320m -XX:+HeapDumpOnOutOfMemoryError -Xmx4g
14+
15+
# Enable parallel execution
1316
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
14-
# org.gradle.parallel=true
17+
org.gradle.parallel=true
18+
1519
# AndroidX package structure to make it clearer which packages are bundled with the
1620
# Android operating system, and which are packaged with your app's APK
1721
# https://developer.android.com/topic/libraries/support-library/androidx-rn
@@ -30,6 +34,15 @@ android.nonTransitiveRClass=true
3034
# https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:configuration_on_demand
3135
org.gradle.caching=true
3236

37+
# Enable configuration caching
38+
# https://docs.gradle.org/current/userguide/configuration_cache.html
39+
org.gradle.configuration-cache=true
40+
org.gradle.configuration-cache.parallel=true
41+
3342
# Enable Gradle's daemon mode, which is faster and more stable than the current
3443
# https://docs.gradle.org/current/userguide/gradle_daemon.html
35-
org.gradle.daemon=true
44+
org.gradle.daemon=true
45+
46+
# Disable unused build features
47+
android.defaults.buildfeatures.resvalues=false
48+
android.defaults.buildfeatures.shaders=false

0 commit comments

Comments
 (0)