api / org.gradle.kotlin.dsl / org.gradle.api.plugins.ExtensionContainer / getByName

getByName

inline fun <reified T : Any> ExtensionContainer.getByName(name: String): T

Looks for the extension of a given name and casts it to the expected type T.

If none found it will throw an UnknownDomainObjectException. If the extension is found but cannot be cast to the expected type it will throw an IllegalStateException.

Parameters

name - extension name

Exceptions

UnknownDomainObjectException - When the given extension is not found.

IllegalStateException - When the given extension cannot be cast to the expected type.

Return
extension, never null