gradle - Gradle 构建问题:无法在咖啡因模拟器中获取未知属性“库”
问题描述
我曾经使用 Eclipse 在我的 Caffeine's Simulator 分支上工作,并且该项目已编译并构建好。
突然,我在运行 Gradle 构建时开始收到以下错误:
Could not get unknown property 'libraries' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我确实不理解 Caffeine 的 Simulator build.gradle 依赖项中的语法“implementation libraries.X”。
为了研究这个问题,我在 Eclipse 中生成了 MWE 项目,其 build.gradle 如下:
plugins {
id 'java-library'
}
repositories {
jcenter()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:28.2-jre'
testImplementation 'junit:junit:4.12'
implementation libraries.xz
}
这个 MWE 给出了同样的错误。删除行 implementation libraries.xz 后,项目构建正常。
我猜“库”是在咖啡因某处定义的属性/变量,但找不到它。
解决方案
依赖项的清单在 dependencies.gradle 中定义。根构建文件将此应用于所有子项目,
subprojects {
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "${rootDir}/gradle/publish.gradle"
apply from: "${rootDir}/gradle/codeQuality.gradle"
apply from: "${rootDir}/gradle/dependencies.gradle"
...
}
中央清单允许更抽象地引用依赖项,以便可以全局升级版本并减少复制和粘贴问题。
这听起来像是对构建的本地更改导致它不再导入清单并且无法解析属性。
推荐阅读
- xamarin - XF 4.6 pre 是否需要设置“CarouselView_Experimental”、“SwipeView_Experimental”、“IndicatorView_Experimental”?
- javascript - css和html的导航栏问题
- flutter - Flutter:解析 JSON 数据并在 App 中展示
- java - 如何使用 terser 从 hl7 v2.6 消息中获取特定字段的各种组件?
- python - 使用 scrapy 抓取简单网站时出现 503 Service Unavailable 错误
- php - Laravel 静态 Create 方法插入记录返回 null id
- linux - 可以将当前日期添加到 rsync 工作路径吗?
- docker - elasticbeanstalk 部署失败,来自守护进程的错误响应:
- python - 在 Python/tkinter 中,检测是否使用 SSH 的最佳方法是什么,因此 Windows 不可用?
- python - 是否可以将批次的总和而不是批次的平均值显示为keras中的损失?