gradle 插件 DSL 中的参考版本变量?
Reference version variable in gradle plugin DSL?
我有以下文件:
buildscript {
ext {
kotlinVersion = '1.2.10'
springBootVersion = '2.0.0.M7'
}
...
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.10"
我想在 plugins
声明中使用 ext
块中的 kotlinVersion
。我怎样才能做到这一点?
当我尝试直接这样做时,我得到:
argument list must be exactly 1 literal non empty string
您不能在插件 DSL 中引用变量,
Plugin docs参考如下:
Where «plugin version» and «plugin id» must be constant, literal,
strings and the apply statement with a boolean can be used to disable
the default behavior of applying the plugin immediately (e.g. you want
to apply it only in subprojects). No other statements are allowed;
their presence will cause a compilation error.
使用pluginManagement
块。
https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management
我有以下文件:
buildscript {
ext {
kotlinVersion = '1.2.10'
springBootVersion = '2.0.0.M7'
}
...
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.10"
我想在 plugins
声明中使用 ext
块中的 kotlinVersion
。我怎样才能做到这一点?
当我尝试直接这样做时,我得到:
argument list must be exactly 1 literal non empty string
您不能在插件 DSL 中引用变量,
Plugin docs参考如下:
Where «plugin version» and «plugin id» must be constant, literal, strings and the apply statement with a boolean can be used to disable the default behavior of applying the plugin immediately (e.g. you want to apply it only in subprojects). No other statements are allowed; their presence will cause a compilation error.
使用pluginManagement
块。
https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management