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

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
  }
}

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 ""Build cache is disabled""?
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 "Build cache is disabled"?
Turn on caching for every invocation via gradle.properties.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card