Expected When publishing a maven artifact, dynamic version specifier ‘+’ for dependencies is replaced with actual latest version of the dependency in the generated Maven pom
Actual The generated pom of the published artifact leaves ‘+’ as the version specifier, which is not valid Maven syntax
In case it helps others this is how I’m working around the issue for now:
mavenDeployer {
pom.whenConfigured { p ->
// get all unresolved dependencies in the pom
def unresolved = p.getDependencies()
.grep { it.version == '+' }
for (u in unresolved) {
def artifact =
"${u.groupId}:${u.artifactId}:${u.version}"
// crawl each configuration and try to find a resolution
// result for the unresolved artifact
def resolved
for ( c in project.configurations) {
def deps = c.incoming
.getResolutionResult()
.getAllDependencies()
// a matching resolution result will have a requested
// artifact name identical to the unresolved artifact
resolved =
deps.grep { "${it.getRequested()}" == artifact }
.getAt(0)
if (resolved) {
break
}
}
if (resolved) {
// now replace the unresolved version with the
// version selected by the resolution result
u.version = resolved.getSelected()
.getModuleVersion()
.getVersion()
}
}
}
}