ext in buildscript can not be recognised by Gradle Kotlin DSL -
in these days, trying write codes experience spring reactive features , kotlin extension in spring 5, , prepared gradle kotlin dsl build.gradle.kt configure gradle build.
the build.gradle.kt
converted spring boot template codes generated http://start.spring.io.
but ext
in buildscript
can not detected gradle.
buildscript { ext { } }
the ext
cause gradle build error.
to make variables in classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinversion")
, compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinversion")
work, added variables in hard way.
val kotlinversion = "1.1.4" val springbootversion = "2.0.0.m3"
but have declare them in global top location , duplicate them in buildscript
.
code: https://github.com/hantsy/spring-reactive-sample/blob/master/kotlin-gradle/build.gradle.kts
is there graceful approach make ext
work?
update: there ugly approaches:
from gradle kotlin dsl example, https://github.com/gradle/kotlin-dsl/tree/master/samples/project-properties, declares properties in gradel.properties.
kotlinversion = 1.1.4 springbootversion = 2.0.0.m3
and use in build.gradle.kts.
buildscript{ val kotlinversion project } val kotlinversion project //another declare out of buildscript block.
similar above declare them in buildscript block:
buildscript{ extra["kotlinversion"] = "1.1.4" extra["springbootversion"] = "2.0.0.m3" val kotlinversion: string } val kotlinversion: string extra//another declare out of buildscript block.
how can avoid duplication of val kotlinversion: string extra?
Comments
Post a Comment