# setOnlyIf

open fun setOnlyIf(spec: Spec<in Task>)(source)

Execute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.

The given predicate replaces all such predicates for this task.

#### Since

0.9

#### Parameters

onlyIfSpec

specifies if a task should be run

open fun setOnlyIf(onlyIfReason: String, spec: Spec<in Task>)(source)

Execute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.

The given predicate replaces all such predicates for this task.

#### Since

7.6

#### Parameters

onlyIfReason

specifies the reason for a task to run, which is used for logging

onlyIfSpec

specifies if a task should be run

open fun setOnlyIf(onlyIfClosure: Closure)(source)

Execute the task only if the given closure returns true. The closure will be evaluated at task execution time, not during configuration. The closure will be passed a single parameter, this task. If the closure returns false, the task will be skipped.

The given predicate replaces all such predicates for this task.

#### Since

0.9

#### Parameters

onlyIfClosure

code to execute to determine if task should be run