How to disable gradle's local build cache, but keep remote cache enabled?

Viewed 2346

I'm trying to do some benchmarking and performance testing for my Android app and want to see how gradle is using the build cache.

I have a remote build cache configured and working. I want to test it, but I can't find a flag or option to disable the local cache specifically while keeping the remote enabled.

1 Answers

Both the local and remote cache can be enabled and disabled individually, but it has to be done in the settings file. Your use case happens to be identical to what you usually want a CI server to do (only use a remote cache and not a local one) for which there is an example of in the user guide. Something like this:

buildCache {
    local {
        enabled = false
    }
    remote(HttpBuildCache) {
        enabled = true
        url = 'https://example.com:8123/cache/'
    }
}

If you need to troubleshoot the use of the build cache (e.g. unexpected cache misses), run with -Dorg.gradle.caching.debug=true.

Related