我正在使用 Gradle 6.9.2,我注意到有机会定义一个没有任何版本的依赖约束,比如
dependencies {
constraints {
implementation 'org.apache.commons:commons-compress'
}
}
生成的 .module 文件将具有 NULL 版本:
"dependencyConstraints": [
{
"group": "org.apache.commons",
"module": "commons-compress"
}
如果我们尝试添加这种类型的库(dep 约束为 NULL 版本),我们的构建将失败
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve {lib_with_incorrect_dep_constraint}.
Required by:
project {project-name}
Caused by: java.lang.NullPointerException
几个问题:
- 没有任何版本的依赖约束有什么意义吗?
- 在发布此类库之前,有什么方法可以启用任何类型的验证吗?
- 有什么方法可以禁用从依赖库中读取依赖约束部分?
回答1
验证在 Gradle https://github.com/gradle/gradle/issues/20791 中无法正常工作 将在 6.9.3 和 7.5 中修复