3

有没有办法使用gradlew/列出给定 bom 为 gradle 贡献的所有属性gradle

假设我有以下构建脚本

  dependencies {
    //*** bill of materials
    springBom platform("org.springframework.boot:spring-boot-dependencies:2.1.2.RELEASE")
  }

我想列出作为 bom 一部分可用的所有属性,我该怎么做?

我知道它贡献了一个名为的属性,micrometer.version因为消息来源是这样说的

参考:https ://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-dependencies/pom.xml

4

2 回答 2

3

io.spring.dependency-management插件使导入的 BOM 中的所有属性都可用于您的 Gradle 构建。

因此,基本上,您可以编写自定义 gradle 任务来打印所有这些。

tasks.register("spring-boot-properties") { 
    group = 'Introspection'
    description = 'Print properties from all BOMs'
    doLast { 
        println dependencyManagement.importedProperties
    }
}

然后只需执行任务:./gradlew spring-boot-properties

于 2019-02-09T17:41:59.930 回答
2

Maven BOM support in Gradle does not expose that information. The properties are effectively inlined when parsing the POM hierarchy and thus no longer available in the dependency metadata format of Gradle.

As commented in the other answer, using the Spring dependency-management-plugin gives you access to these values.

于 2019-02-11T15:12:21.830 回答