# registerIfAbsent

abstract fun <T : BuildService<P>?, P : BuildServiceParameters?> registerIfAbsent(name: String, implementationType: Class<T>, configureAction: Action<in BuildServiceSpec<P>>): Provider<T>(source)

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.

#### Return

A Provider that will create the service instance when queried.

#### Parameters

name

A name to use to identify the service.

implementationType

The service implementation type. Instances of the service are created as for newInstance.

configureAction

An action to configure the registration. You can use this to provide parameters to the service instance.

open fun <T : BuildService<P>?, P : BuildServiceParameters?> registerIfAbsent(name: String, implementationType: Class<T>): Provider<T>(source)

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.

#### Return

A Provider that will create the service instance when queried.

#### Since

8.7

#### Parameters

name

A name to use to identify the service.

implementationType

The service implementation type. Instances of the service are created as for newInstance.