diff --git a/amethyst/build.gradle.kts b/amethyst/build.gradle.kts index e4df9eb8bf..730f044c4e 100644 --- a/amethyst/build.gradle.kts +++ b/amethyst/build.gradle.kts @@ -1,4 +1,7 @@ +import org.gradle.api.services.BuildService +import org.gradle.api.services.BuildServiceParameters import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { alias(libs.plugins.androidApplication) @@ -342,6 +345,25 @@ kotlin { } } +// Gradle schedules Kotlin compilations of different variants of this module +// concurrently (e.g. playDebug + playBenchmark when CI runs unit tests, lint, +// and assembleBenchmark in one invocation), but they all share a single Kotlin +// daemon whose heap (kotlin.daemon.jvmargs) cannot fit two full :amethyst +// codegen passes — CI runs died with "GC overhead limit exceeded" inside the +// daemon. This no-op shared build service with maxParallelUsages = 1 tells the +// scheduler to run this module's Kotlin compile tasks one at a time; other +// projects' tasks (JVM tests, lint analysis, packaging) still run in parallel. +abstract class AmethystKotlinCompileLimiter : BuildService + +val kotlinCompileLimiter = + gradle.sharedServices.registerIfAbsent("amethystKotlinCompileLimiter", AmethystKotlinCompileLimiter::class) { + maxParallelUsages.set(1) + } + +tasks.withType().configureEach { + usesService(kotlinCompileLimiter) +} + composeCompiler { reportsDestination = layout.buildDirectory.dir("compose_compiler") metricsDestination = layout.buildDirectory.dir("compose_compiler")