gradle
8.5

# whenTaskAdded

abstract fun whenTaskAdded(action: Action<out Any>): Action<out Any>(source)

Adds an `Action` to be executed when a task is added to this collection.

Like all, this method will cause all tasks in this container to be realized.

#### Return

the supplied action

#### Parameters

action

The action to be executed

abstract fun whenTaskAdded(closure: Closure)(source)

Adds a closure to be called when a task is added to this collection. The task is passed to the closure as the parameter.

#### Parameters

closure

The closure to be called

#### See also

whenTaskAdded(Action)