api / org.gradle.kotlin.dsl / kotlin.Any / withConvention

withConvention

inline fun <ConventionType : Any, ReturnType> Any.withConvention(conventionType: KClass<ConventionType>, function: ConventionType.() -> ReturnType): ReturnType

Evaluates the given function against the convention plugin of the given conventionType.

Parameters

conventionType - the type of the convention to be located.

function - function to be evaluated.

Exceptions

IllegalStateException - When the receiver does not support convention plugins, when there is no convention plugin of the given type, or when there are multiple such plugins.

Return
the value returned by the given function.

See Also

Convention.getPlugin