BuildServiceRegistry (Gradle API 8.14.1)
Description: declaration: package: org.gradle.api.services, interface: BuildServiceRegistry

Package org.gradle.api.services

# Interface BuildServiceRegistry

public interface BuildServiceRegistry
A registry of build services. You use this type to register service instances.

A registry is available using `Gradle.getSharedServices()`.

Since:
  6.1

- ## Method Summary

  Modifier and Type
  Method
  Description
  `NamedDomainObjectSet<BuildServiceRegistration<?,?>>`
  `getRegistrations()`
  Returns the set of service registrations.
  `default <T extends BuildService<P>, P extends BuildServiceParameters>
  Provider<T>`
  `registerIfAbsent(String name, Class<T> implementationType)`
  Registers a service, if a service with the given name is not already registered.
  `<T extends BuildService<P>, P extends BuildServiceParameters>
  Provider<T>`
  `registerIfAbsent(String name, Class<T> implementationType, Action<? super BuildServiceSpec<P>> configureAction)`
  Registers a service, if a service with the given name is not already registered.

- ## Method Details

  - ### getRegistrations

    NamedDomainObjectSet<BuildServiceRegistration<?,?>> getRegistrations()
    Returns the set of service registrations.

  - ### registerIfAbsent

    <T extends BuildService<P>, P extends BuildServiceParameters> Provider<T> registerIfAbsent(String name, Class<T> implementationType, Action<? super BuildServiceSpec<P>> configureAction)
    Registers a service, if a service with the given name is not already registered. The service is not created until required, when the returned `Provider` is queried.
    Parameters:
      `name` - A name to use to identify the service.
      `implementationType` - The service implementation type. Instances of the service are created as for `ObjectFactory.newInstance(Class, Object...)`.
      `configureAction` - An action to configure the registration. You can use this to provide parameters to the service instance.
    Returns:
      A `Provider` that will create the service instance when queried.

  - ### registerIfAbsent

    default <T extends BuildService<P>, P extends BuildServiceParameters> Provider<T> registerIfAbsent(String name, Class<T> implementationType)
    Registers a service, if a service with the given name is not already registered. The service is not created until required, when the returned `Provider` is queried.
    Parameters:
      `name` - A name to use to identify the service.
      `implementationType` - The service implementation type. Instances of the service are created as for `ObjectFactory.newInstance(Class, Object...)`.
    Returns:
      A `Provider` that will create the service instance when queried.
    Since:
      8.7