gradle
8.4

# onTaskCompletion

abstract fun onTaskCompletion(listener: Provider<out OperationCompletionListener>)(source)

Subscribes the given listener to the finish events for tasks, if not already subscribed. The listener receives a org.gradle.tooling.events.task.TaskFinishEvent as each task completes.

The events are delivered to the listener one at a time, so the implementation does not need to be thread-safe. Also, events are delivered to the listener concurrently with task execution and other work, so event handling does not block task execution. This means that a task finish event is delivered to the listener some time "soon" after the task has completed. The events contain timestamps to allow you collect timing information.

The listener is automatically unsubscribed when the build finishes.

#### Parameters

listener

The listener to receive events. This must be a org.gradle.api.services.BuildService instance, see org.gradle.api.services.BuildServiceRegistry.