api / org.gradle.api / NamedDomainObjectCollection / getByName

getByName

abstract fun getByName(name: String): T

Locates an object by name, failing if there is no such object.

Parameters

name - The object name

Exceptions

UnknownDomainObjectException - when there is no such object in this collection.

Return
The object with the given name. Never returns null.

abstract fun getByName(name: String, configureClosure: Closure<Any>): T

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

Parameters

name - The object name

configureClosure - The closure to use to configure the object.

Exceptions

UnknownDomainObjectException - when there is no such object in this collection.

Return
The object with the given name, after the configure closure has been applied to it. Never returns null.

abstract fun getByName(name: String, configureAction: Action<in T>): T

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

Parameters

name - The object name

configureAction - The action to use to configure the object.

Exceptions

UnknownDomainObjectException - when there is no such object in this collection.

Return
The object with the given name, after the configure action has been applied to it. Never returns null.

Since
3.1