Package org.gradle.build.event

# Interface BuildEventsListenerRegistry

public interface BuildEventsListenerRegistry
Allows a plugin to receive information about the operations that run within a build.

An instance of this registry can be injected into tasks, plugins and other objects by annotating a public constructor or property getter method with `javax.inject.Inject`.

Since:
  6.1

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `onTaskCompletion(Provider<? extends OperationCompletionListener> listenerProvider)`
  Subscribes the listener provided by `listenerProvider` to the finish events for tasks, if not already subscribed.

- ## Method Details

  - ### onTaskCompletion

    void onTaskCompletion(Provider<? extends OperationCompletionListener> listenerProvider)
    Subscribes the listener provided by `listenerProvider` to the finish events for tasks, if not already subscribed. The listener receives a `TaskFinishEvent` as each task completes.

    The events are delivered to the listener one at a time, so the implementation does not need to support concurrent notifications. 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.

    In order to support Configuration Cache, the `listenerProvider` must be a provider returned directly from `BuildServiceRegistry.registerIfAbsent(String, Class, Action)` or `BuildServiceRegistration.getService()`

    Parameters:
      `listenerProvider` - The provider of listener to receive events. The implementation of the listener must be a `BuildService` instance, see `BuildServiceRegistry`.