任务输出缓存已启用,但未配置或启用构建缓存

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

我已配置 buildCache {} 部分启用了远程缓存,但日志显示

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

我错过了什么?

启用构建缓存但 both the local and remote caches are disabled

时会记录此警告

您是否无意中以某种方式禁用了它们,例如通过某些未按预期工作的 isCiServer 逻辑?您可以分享您的 buildCache 配置吗?

将如下内容添加到您的 settings.gradle(使用适合您的缓存实例的 url):

ext.isCiServer = System.getenv().containsKey("CI")

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

并添加

org.gradle.caching=true

给你的gradle.properties,或

--build-cache

您的命令行应该足以使构建缓存正常工作。