Optimize build times (#6418)

This commit is contained in:
David Perez
2026-01-27 13:01:20 -06:00
committed by GitHub
parent 66316e4bd2
commit 954571ff4a
11 changed files with 105 additions and 61 deletions

View File

@@ -299,16 +299,16 @@ dependencies {
testImplementation(libs.square.turbine) testImplementation(libs.square.turbine)
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
// Explicitly setting the user Country and Language because tests assume en-US jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
"-Duser.country=US" + // Explicitly setting the user Country and Language because tests assume en-US
"-Duser.language=en" "-Duser.country=US" +
} "-Duser.language=en"
} }
afterEvaluate { afterEvaluate {

View File

@@ -260,10 +260,16 @@ protobuf {
} }
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
} forkEvery = 100
maxHeapSize = "2g"
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }
private fun renameFile(path: String, newName: String) { private fun renameFile(path: String, newName: String) {

View File

@@ -76,8 +76,14 @@ dependencies {
testImplementation(libs.square.turbine) testImplementation(libs.square.turbine)
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
} forkEvery = 100
maxHeapSize = "2g"
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -179,6 +179,12 @@ fun Project.getGitStagedFiles(rootDir: File): Provider<List<File>> {
} }
} }
subprojects {
tasks.withType<JavaCompile>().configureEach {
options.isFork = true
}
}
afterEvaluate { afterEvaluate {
tasks.withType(Detekt::class.java).configureEach { tasks.withType(Detekt::class.java).configureEach {
val typeResolutionEnabled = !classpath.isEmpty val typeResolutionEnabled = !classpath.isEmpty

View File

@@ -69,11 +69,14 @@ kotlin {
} }
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
} jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -64,11 +64,14 @@ dependencies {
testImplementation(libs.mockk.mockk) testImplementation(libs.mockk.mockk)
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
} jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -74,11 +74,14 @@ dependencies {
testFixturesImplementation(libs.kotlinx.coroutines.test) testFixturesImplementation(libs.kotlinx.coroutines.test)
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
} jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -5,5 +5,13 @@ kotlin.code.style=official
kotlin.compilerArgs=-Xjspecify-annotations=strict, -Xtype-enhancement-improvements-strict-mode kotlin.compilerArgs=-Xjspecify-annotations=strict, -Xtype-enhancement-improvements-strict-mode
org.gradle.caching=true org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8
org.gradle.parallel=true org.gradle.parallel=true
# Disable build features that are enabled by default and we do not need
# developer.android.com/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures
android.defaults.buildfeatures.renderscript=false
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false

View File

@@ -79,11 +79,14 @@ dependencies {
testFixturesImplementation(libs.square.okhttp.mockwebserver) testFixturesImplementation(libs.square.okhttp.mockwebserver)
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
} jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -118,10 +118,14 @@ dependencies {
testImplementation(testFixtures(project(":ui"))) testImplementation(testFixtures(project(":ui")))
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
} maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
// Explicitly setting the user Country and Language because tests assume en-US
"-Duser.country=US" +
"-Duser.language=en"
} }

View File

@@ -114,13 +114,15 @@ kotlin {
} }
} }
tasks { tasks.withType<Test>().configureEach {
withType<Test> { useJUnitPlatform()
useJUnitPlatform() @Suppress("MagicNumber")
maxHeapSize = "2g" forkEvery = 100
maxParallelForks = Runtime.getRuntime().availableProcessors() maxHeapSize = "2g"
@Suppress("UselessCallOnNotNull") maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC" +
android.sourceSets["main"].res.srcDirs("src/test/res") // Explicitly setting the user Country and Language because tests assume en-US
} "-Duser.country=US" +
"-Duser.language=en"
android.sourceSets["main"].res.srcDirs("src/test/res")
} }