Can't use project extra properties in plugin block

前端 未结 3 920
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 11:54

I have a multi-project build, and more often than not I find myself locking versions for artifacts across the board. So in my root project I define something like:

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 12:21

    Apparently this has become possible recently, if it wasn't possible in the past. (Almost) from the docs:

    gradle.properties:

    helloPluginVersion=1.0.0
    

    settings.gradle.kts:

    pluginManagement {
      val helloPluginVersion: String by settings
      plugins {
        id("com.example.hello") version helloPluginVersion
      }
    }
    

    And now the docs say that build.gradle.kts should be empty but my testing shows that you still need this in build.gradle.kts:

    plugins {
      id("com.example.hello")
    }
    

    The version is now determined by settings.gradle.kts and hence by gradle.properties which is what we want...

提交回复
热议问题