ext in buildscript can not be recognised by Gradle Kotlin DSL

前端 未结 5 1789
走了就别回头了
走了就别回头了 2021-01-31 07:39

In these days, I am trying to write some codes to experience the Spring reactive features and kotlin extension in Spring 5, and I also prepared a gradle Kotlin DSL build.gradle

5条回答
  •  伪装坚强ぢ
    2021-01-31 08:41

    What is working for me is using ext in allprojects instead of buildscript, so in your top-level build.gradle.kts

    allprojects {
      ext {
        set("supportLibraryVersion", "26.0.1")
      }
    }
    

    then you can use it in build.gradle.kts files in modules like this:

    val supportLibraryVersion = ext.get("supportLibraryVersion") as String
    

提交回复
热议问题