我曾经使用Eclipse对我的Caffeine's Simulator的分叉进行工作,项目的编译和构建都很正常。
突然,我在运行Gradle构建时,开始得到以下错误。
Could not get unknown property 'libraries' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我确实不理解Caffeine's Simulator build.gradle dependencies中的语法 "implemental 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给出了同样的错误。 执行库.xz项目构建正常。
我猜测 "库 "是Caffeine中某处定义的一个属性变量,但没有找到。
依赖关系的清单定义在 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"
...
}
中央清单允许更抽象地引用依赖关系,因此可以在全局范围内升级版本,并减少复制和粘贴问题。
听起来像是对构建的局部更改导致它不再导入清单,属性无法解决。