[英]Gradle 6 migration settings.gradle.kts
I've got the following code in the settings.gradle.kts
, which is works fine in gradle 5
我在
settings.gradle.kts
中有以下代码,在gradle 5
中运行良好
rootProject.name = "server"
val pluginsRepoUrl: String by settings
val repoUsername: String by settings
val repoPassword: String by settings
pluginManagement {
repositories {
maven {
url = uri(pluginsRepoUrl)
credentials {
username = repoUsername
password = repoPassword
}
}
}
}
I want to upgrade to gradle 6
but this code is not works and gives me a following error:我想升级到
gradle 6
,但这段代码不起作用,并出现以下错误:
e: .../settings.gradle.kts:10:23: Unresolved reference: pluginsRepoUrl
The values comes from the gradle.properties
file.这些值来自
gradle.properties
文件。
In Gradle 6, the behavior of the pluginManagement {}
block was changed :在 Gradle 6 中,
pluginManagement {}
块的行为发生了变化:
Previously, any
pluginManagement {}
blocks inside a settings script were executed during the normal execution of the script.以前,设置脚本中的任何
pluginManagement {}
块都是在脚本的正常执行期间执行的。Now, they are executed earlier in a similar manner to
buildscript {}
orplugins {}
.现在,它们以类似于
buildscript {}
或plugins {}
的方式更早地执行。 This means that code inside such a block cannot reference anything declared elsewhere in the script.这意味着此类块内的代码不能引用脚本中其他地方声明的任何内容。
(emphasis mine) (强调我的)
This means that you cannot reference the variables declared outside of that block.这意味着您不能引用在该块之外声明的变量。 To fix this, move those declarations inside the
pluginManagement {}
block:要解决此问题,请将这些声明移到
pluginManagement {}
块中:
pluginManagement {
val pluginsRepoUrl: String by settings
val repoUsername: String by settings
val repoPassword: String by settings
repositories {
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.