How to parametrize Kotlin version in the plugins block of a build.gradle.kts script?
Short answer:
There is currenlty no way of accessing anything of the outer scope from inside the lambda passed to plugins
.
Long answer:
In case you use IntelliJ it will show you a bit more information:
'val kotlinVersion: String' can't be called in this context by implicit receiver. Use the explicit one if necessary.
The outer scope (this@Build_gradle
) where you define kotlinVersion
is not avaiable in the this@plugins
scope so you have to define kotlinVersion
inside the plugins lambda.
Since the extra
delegate isn't available there either you can't use it:
plugins {
val kotlinVersion = "1.3.61"
// ...
}
Unfortunately using a label does not work:
val kotlinVersion by extra ("1.3.61")
plugins {
// ... Unresolved reference: kotlinVersion
kotlin("jvm") version this@Build_gradle.kotlinVersion
}