我有一个项目,该项目有另一个依赖项,都依赖于Spring IO Platform来解决依赖项。有一个旧式检查可以验证它们是否都依赖于相同版本的Spring平台。当我进行独立构建并看起来像这样时,检查会起作用
check {
def dependency = project.dependencies.create(libs.something_commons_api + "@pom")
def configuration = project.configurations.detachedConfiguration(dependency)
def pomFile = configuration.resolve().iterator().next()
GPathResult commonsPom = new XmlSlurper().parse(pomFile)
def platformBomDependencyVersion = commonsPom.dependencyManagement.dependencies.dependency.find {
it.artifactId == 'platform-bom'
}?.version?.toString()
assert libs.spring_platform_version == platformBomDependencyVersion
}
对我来说,这看起来很骇人,更重要的是,在复合版本中不起作用:
problem occurred evaluating project ':some:project'.
> Could not resolve all files for configuration ':some:project:detachedConfiguration1'.
> Could not find something-commons-api.pom (project :something-common:something-commons-api).
实现此目标的正确方法是什么?