1 2 3 4 5 6 7 8 9 10
import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.findByType inline fun <reified T : Any> ExtensionAware.configureIf(crossinline block: T.() -> Unit) { if (extensions.findByType<T>() != null) { extensions.configure<T> { block() } } }