diff --git a/build-logic/aggregator/settings.gradle.kts b/build-logic/aggregator/settings.gradle.kts index 06bfee11f2..79b620d0d9 100644 --- a/build-logic/aggregator/settings.gradle.kts +++ b/build-logic/aggregator/settings.gradle.kts @@ -1,6 +1,9 @@ buildCache { local { - directory = file("../../.gradle/build-cache") + // As in the root build: each checkout keeps its own cache, and CI keeps it in the Gradle user home. + if (!providers.environmentVariable("CI").isPresent) { + directory = file("../../.gradle/build-cache") + } } } diff --git a/build-logic/common-plugins/settings.gradle.kts b/build-logic/common-plugins/settings.gradle.kts index 1fe7567ea1..20639aa33b 100644 --- a/build-logic/common-plugins/settings.gradle.kts +++ b/build-logic/common-plugins/settings.gradle.kts @@ -1,6 +1,9 @@ buildCache { local { - directory = file("../../.gradle/build-cache") + // As in the root build: each checkout keeps its own cache, and CI keeps it in the Gradle user home. + if (!providers.environmentVariable("CI").isPresent) { + directory = file("../../.gradle/build-cache") + } } } diff --git a/build-logic/settings-plugins/settings.gradle.kts b/build-logic/settings-plugins/settings.gradle.kts index d561ab88d6..2d8fe19505 100644 --- a/build-logic/settings-plugins/settings.gradle.kts +++ b/build-logic/settings-plugins/settings.gradle.kts @@ -1,6 +1,9 @@ buildCache { local { - directory = file("../../.gradle/build-cache") + // As in the root build: each checkout keeps its own cache, and CI keeps it in the Gradle user home. + if (!providers.environmentVariable("CI").isPresent) { + directory = file("../../.gradle/build-cache") + } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index f135e29630..67ec3043a7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,7 +32,12 @@ buildCache { // of this repository build concurrently (e.g., ../research-fork and ../gradle94). // Without this, both projects share ~/.gradle/caches/build-cache-1/ and concurrent // writes can corrupt cached artifacts (ZipFile invalid LOC header errors). - directory = file(".gradle/build-cache") + // CI builds one checkout at a time and keeps the cache in the Gradle user home, which + // setup-gradle saves after master's runs and restores for later runs, so that a run + // reuses what an earlier one built. + if (!providers.environmentVariable("CI").isPresent) { + directory = file(".gradle/build-cache") + } } }