Gradle "Build cache is disabled" - Enable Caching in CI
Gradle reported that its build cache is disabled, so it cannot reuse task outputs from a previous run. Nothing breaks, but every CI build does the full work - compilation, tests, packaging - even when nothing changed.
What this error means
A --scan or info-level log shows Build cache is disabled, and CI builds take the same long time regardless of how small the change is. Tasks never report FROM-CACHE.
> Task :compileJava
Build cache is disabled
Calculating task graph as no cached configuration is available...
BUILD SUCCESSFUL in 6m 12s # full rebuild every runDiagnose it: get the real failure out of Gradle
Gradle summarises failures aggressively, and the top-level message frequently describes a downstream symptom rather than the cause. Re-run the failing task with diagnostics before changing build logic.
# the actual stack, plus what Gradle decided about the build
./gradlew <task> --stacktrace --info
# is a stale daemon or cache involved?
./gradlew --stop
./gradlew <task> --no-daemon --no-build-cache
# what does Gradle think the environment is?
./gradlew -versionCommon causes
org.gradle.caching is not set
The build cache is off by default; without org.gradle.caching=true (or --build-cache) Gradle never stores or reuses outputs.
No persistent cache directory in CI
Even with caching on, an ephemeral runner with no cached ~/.gradle starts empty every time, so there is nothing to reuse.
No remote build cache configured
Local-only cache does not survive across runners; without a shared remote cache, parallel jobs cannot share outputs.
How to fix it
Enable the build cache
Turn on caching for every invocation via gradle.properties.
# gradle.properties
org.gradle.caching=truePersist the Gradle caches in CI
Cache the user home so local cache entries survive between runs.
# cache key on wrapper + build scripts
~/.gradle/caches
~/.gradle/wrapperConfigure a remote build cache
Share outputs across runners with a remote cache backend.
// settings.gradle
buildCache {
remote(HttpBuildCache) {
url = 'https://gradle-cache.example.com/cache/'
push = System.getenv('CI') != null
}
}Configuration cache and CI
- The configuration cache rejects build logic that reads mutable state at execution time, which is why enabling it surfaces errors an existing build never showed.
- Run with
--configuration-cache-problems=warnfirst to see the full list rather than failing on the first one. - A cached configuration keyed to a different environment is worse than none. Include the JDK version in your cache key.
How to prevent it
- Keep
org.gradle.caching=truecommitted ingradle.properties. - Persist
~/.gradle/cachesand~/.gradle/wrapperbetween CI runs. - Use a remote build cache so outputs are shared across runners and PRs.