api / org.gradle.api.tasks / TaskOutputs / doNotCacheIf

doNotCacheIf

abstract fun doNotCacheIf(cachingDisabledReason: String, spec: Spec<in Task>): Unit

Disable caching the results of the task if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration.

As opposed to #cacheIf(String, Spec), this method never enables caching for a task, it can only be used to disable caching.

You may add multiple such predicates. The results of the task are not cached if any of the predicates return true, or if any of the predicates passed to #cacheIf(String, Spec) returns false.

Parameters

cachingDisabledReason - the reason why caching would be disabled by the spec.

spec - specifies if the results of the task should not be cached.

Since
3.4