api / org.gradle.api.plugins / ExtensionContainer / getByType

getByType

abstract fun <T : Any> getByType(type: Class<T>): T

Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.

Parameters

type - extension type

Exceptions

UnknownDomainObjectException - When the given extension is not found.

Return
extension, never null

@Incubating abstract fun <T : Any> getByType(type: TypeOf<T>): T

Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.

Parameters

type - extension type

Exceptions

UnknownDomainObjectException - When the given extension is not found.

Return
extension, never null

Since
3.5