【发布时间】:2019-02-27 19:31:54
【问题描述】:
我有一个 Gradle Task 从项目中提取依赖项并使用该数据。下面是我的Gradle Task
task gavValidation() {
doLast {
project(':app').configurations.each {
configurationType ->
println "configurationType >>> "+configurationType.name
configurationType.allDependencies.each {
gav ->
println gav.group+" : "+gav.name+" : "+gav.version
}
}
}
}
print 语句在上面打印gav.version 时总是以null 出现。
我发现,这些依赖项的版本都在Spring Dependency Management Plugin 中维护。下面是sn-p
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE'
mavenBom 'io.pivotal.spring.cloud:spring-cloud-services-dependencies:1.5.0.RELEASE'
mavenBom 'org.springframework.boot:spring-boot-dependencies:1.5.13.RELEASE'
}
dependencies {
dependency 'io.springfox:springfox-swagger2:2.8.0'
dependency 'io.springfox:springfox-swagger-ui:2.8.0'
}
}
如何在我的自定义任务中获取版本?目前为 null
【问题讨论】:
标签: spring spring-boot gradle build.gradle dependency-management