【发布时间】:2020-11-13 13:44:23
【问题描述】:
在 Gradle 6.7 中,我们有一个 dependencyManagement.dependencies 来设置项目的默认值。
最近,有人用 dependencySet 替换了 Spring 的 dependency 行。
dependencySet(group: 'org.springframework.boot', version: "2.2.11.RELEASE") {
entry 'spring-boot-devtools'
entry 'spring-boot-dependencies'
entry 'spring-boot-devtools'
entry 'spring-boot-starter-aop'
entry 'spring-boot-starter-cache'
entry 'spring-boot-starter-webflux'
...
现在在发现一些 CVE 警报后,我发现 Gradle 将 spring-boot-starter-cache 解析为 2.2.8。我不确定它从哪里获得该版本:我们的项目中没有它,并且 deps 树看起来好像是我们自己要求的(它处于 0 级)。
+--- org.springframework.boot:spring-boot-starter-cache -> 2.2.8.RELEASE
当我像以前一样明确添加项目时,
dependency 'org.springframework.boot:spring-boot-starter-cache:2.2.11.RELEASE'
然后它最终被解析为 2.2.11。
+--- org.springframework.boot:spring-boot-starter-cache -> 2.2.11.RELEASE
在 Maven 中,依赖管理非常简单,与此相比:您可以使用依赖管理和 BOM 来控制它,并且一切正常,没有这样的惊喜。
所以也许我在 Gradle 的逻辑中遗漏了一些东西,即使在阅读了依赖管理指南之后。
如何使用类似 BOM 的 dependencySet 来一次控制所有 entry-es?还是我有错误的假设?
【问题讨论】:
标签: gradle dependency-management gradle-dependencies