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:

  1. 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. 
  2. 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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -