Last active
November 3, 2015 15:04
-
-
Save calid/751bef0dd3c59307f368 to your computer and use it in GitHub Desktop.
Manually substitute '+' version specifier in Gradle generated pom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uploadArchives { | |
repositories { | |
mavenDeployer { | |
repository url: 'file:///tmp/testRepo' | |
pom.whenConfigured { p -> | |
// get all unresolved dependencies in our 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 our 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 our 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() | |
} | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment