Skip to content
Latchkey

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.

gradle
> Task :compileJava
Build cache is disabled
Calculating task graph as no cached configuration is available...

BUILD SUCCESSFUL in 6m 12s   # full rebuild every run

Diagnose 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.

Terminal
# 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 -version

Common 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.

properties
# gradle.properties
org.gradle.caching=true

Persist the Gradle caches in CI

Cache the user home so local cache entries survive between runs.

yaml
# cache key on wrapper + build scripts
~/.gradle/caches
~/.gradle/wrapper

Configure a remote build cache

Share outputs across runners with a remote cache backend.

gradle
// 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=warn first 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=true committed in gradle.properties.
  • Persist ~/.gradle/caches and ~/.gradle/wrapper between CI runs.
  • Use a remote build cache so outputs are shared across runners and PRs.

Frequently asked questions

What causes Gradle "Build cache is disabled"?
There are 3 common causes: org.gradle.caching is not set, no persistent cache directory in ci, and no remote build cache configured. The build cache is off by default; without org.gradle.caching=true (or --build-cache) Gradle never stores or reuses outputs.
How do I fix Gradle "Build cache is disabled"?
There are 3 fixes depending on which cause you have: enable the build cache, persist the gradle caches in ci, and configure a remote build cache. Work through them in order, since the first is the most common.
What does Gradle "Build cache is disabled" actually mean?
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.
How do I stop Gradle "Build cache is disabled" happening again?
Keep org.gradle.caching=true committed in gradle.properties. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card