4

I have a Gradle build with both local and remote cache configured. Among other things I use Spotless Gradle plugin. That plugin has marked its tasks (spotlessCheck and spotlessApply) as cacheable. The problem is that in my case task itself is quite fast and thus checking task's output in remote cache takes more time than actually running the task.

So my question: is it possible to disable cache for one task introduced by the 3rd plugin? Even better, is it possible to disable just remote cache for just one task?

Nikem
  • 5,716
  • 3
  • 32
  • 59

2 Answers2

3

I don't think those two particular tasks you mention have the build cache enabled. But other ones like spotlessJava do.

In any case, when you have figured out which tasks use the build cache (e.g. by running with -i), you can configure them with outputs.cacheIf { false }.

Note that this disables both the local and remote build cache. I am not aware of a way to selectively disable just the remote cache for a given task but keep the local one enabled.

For instance:

tasks.named("spotlessJava") {
    outputs.cacheIf { false }
}
Bjørn Vester
  • 6,851
  • 1
  • 20
  • 20
0

I don't think that disabling only the remote cache is possible, but if your problem is that the cache result is too big and it's wasting a lot time trying to upload it (which always fails anyway), you can solve this using the useExpectContinue incubating property.

It will try to check if the upload is possible before doing it, it's good enough for me.

cocorossello
  • 1,289
  • 1
  • 17
  • 30