gradle-extra-configurations-plugin
gradle-extra-configurations-plugin copied to clipboard
Use with gradle kotlin DSL
Can optional be used with the gradle kotlin DSL? If yes, please provide an example. Thanks.
I've used the following workaround, it works but it's a bit ugly:
plugins {
id("nebula.optional-base") version "5.0.0"
}
val optional: Closure<*> by extra
dependencies {
// use optional.toAction() as the 2nd parameter
implementation("...", optional.toAction())
}
with toAction
defined like this
fun <T : Any> Closure<*>.toAction(): Action<T> =
ConfigureUtil.configureUsing(this)