[英]Dependency version not resolved from ext block build.gradle
我在我的build.gradle
文件中添加了一些依賴項,如下所示
ext {
boxableVersion = '1.5.bq'
}
dependencies {
implementation group: "com.github.dhorions", name:'boxable', version:${boxableVersion}
}
在我將 JDK 版本從 1.8 更改為 11 之前,這一直在無縫工作。現在,當我嘗試構建項目時,我的build.gradle
文件中出現以下錯誤
Could not run phased build action using Gradle distribution ' https://services.gradle.org/distributions/gradle-6.0-bin.zip '. 構建文件“/home/christine/christine/projectsFromGit/pdfcreator/build.gradle”行:43 評估根項目“pdfcreator”時出現問題。 Could not find method $() for arguments [build_4fl1snfk49qgbmumnf1gg989h$_run_closure3$_closure11@d7c9f2a] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
如果我像這樣直接給出版本,則項目正在成功構建
implementation group: "com.github.dhorions", name:'boxable', version:'1.5.bq'
我怎樣才能像以前一樣在外部提供版本?
您的依賴項聲明中的以下語法version:${boxableVersion}
無效。 它與您的 JDK 版本無關,只是${...}
在 Gradle DSL 或 Groovy 語法中沒有任何意義。
如果要在“ext”屬性中定義版本,則可以直接使用version: boxableVersion
引用此屬性(通過“groovy 魔術”直接在腳本中提供 ext 屬性),或者可以使用 Groovy字符串插值表示法(請注意雙引號"
)
version: "${boxableVersion}"
或者,以更簡單的方式:
implementation "com.github.dhorions:boxable:${boxableVersion}"
試試看嘛:
ext {
boxableVersion = '1.5.bq'
}
dependencies {
implementation group: "com.github.dhorions", name:'boxable', version:"${boxableVersion}"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.