Search code examples
gradlegradle-plugingradle-cache

Task output caching is enabled, but no build caches are configured or enabled


I have configured buildCache {} section with remote cache enabled, but the log shows

Task output caching is enabled, but no build caches are configured or enabled

What am I missing?


Solution

  • This warning is logged when the build cache is enabled but both the local and remote caches are disabled.

    Have you inadvertently disabled them somehow, e.g. through some isCiServer logic that is not working as intended? Can you share your buildCache config?

    Adding something like the following to your settings.gradle (with the appropriate url for your cache instance):

    ext.isCiServer = System.getenv().containsKey("CI")
    
    buildCache {
        local {
            enabled = !isCiServer
        }
        remote(HttpBuildCache) {
            url = 'https://example.com:8123/cache/'
            push = isCiServer
        }
    }
    

    and either adding

    org.gradle.caching=true
    

    to your gradle.properties, or

    --build-cache
    

    to your command line should be enough to get the build cache working.