gpt4 book ai didi

Gradle 6 迁移 settings.gradle.kts

转载 作者:行者123 更新时间:2023-12-04 03:58:29 27 4
gpt4 key购买 nike

我在 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
}
}
}
}

我要升级到 gradle 6但此代码不起作用,并给了我以下错误:
e: .../settings.gradle.kts:10:23: Unresolved reference: pluginsRepoUrl

这些值来自 gradle.properties文件。

最佳答案

在 Gradle 6 中,the behavior of the pluginManagement {} block was changed :

Previously, any pluginManagement {} blocks inside a settings script were executed during the normal execution of the script.

Now, they are executed earlier in a similar manner to buildscript {} or plugins {}. This means that code inside such a block cannot reference anything declared elsewhere in the script.


(强调我的)
这意味着您不能引用在该块之外声明的变量。要解决此问题,请将这些声明移到 pluginManagement {} 中。堵塞:
pluginManagement {
val pluginsRepoUrl: String by settings
val repoUsername: String by settings
val repoPassword: String by settings
repositories {
...

关于Gradle 6 迁移 settings.gradle.kts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59303742/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com