# register

abstract fun <U : T?> register(name: String, type: Class<U>, configurationAction: Action<in U>): NamedDomainObjectProvider<U>

Defines a new object, which will be created and configured when it is required. A object is 'required' when the object is located using query methods such as getByName or when get is called on the return value of this method.

It is generally more efficient to use this method instead of create or create, as those methods will eagerly create and configure the object, regardless of whether that object is required for the current build or not. This method, on the other hand, will defer creation and configuration until required.

This operation is lazy, the returned element is NOT realized. A lazy wrapper is returned, allowing to continue to use it with other lazy APIs.

#### Return

A Provider whose value will be the object, when queried.

#### Since

4.10

#### Parameters

name

The name of the object.

type

The object type.

configurationAction

The action to run to configure the object. This action runs when the object is required.

<U>

The object type

#### Throws

InvalidUserDataException

If a object with the given name already exists in this project.

abstract fun <U : T?> register(name: String, type: Class<U>): NamedDomainObjectProvider<U>

Defines a new object, which will be created when it is required. A object is 'required' when the object is located using query methods such as getByName or when get is called on the return value of this method.

It is generally more efficient to use this method instead of create or create, as those methods will eagerly create and configure the object, regardless of whether that object is required for the current build or not. This method, on the other hand, will defer creation until required.

This operation is lazy, the returned element is NOT realized. A lazy wrapper is returned, allowing to continue to use it with other lazy APIs.

#### Return

A Provider whose value will be the object, when queried.

#### Since

4.10

#### Parameters

name

The name of the object.

type

The object type.

<U>

The object type

#### Throws

InvalidUserDataException

If a object with the given name already exists in this project.