Support Gradle/maven with multi version artifacts

Previously the publish-maven.gradle only supported having a single
artifact be marked as optional or provided. This causes problems now
that we are building modules that support multiple versions of an
artifact. For example, we compile against two versions of Tiles
artifacts with identical names, both of which need to be marked
optional.

This updates publish-maven.gradle to find all the artifacts and mark
them as optional as apposed to the first entry.
This commit is contained in:
Rob Winch
2012-11-21 10:59:29 -06:00
committed by Rossen Stoyanchev
parent b7f7fae78a
commit 39d419bbc3

View File

@@ -16,10 +16,10 @@ def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// respect 'optional' and 'provided' dependencies
gradleProject.optionalDeps.each { dep ->
generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
generatedPom.dependencies.findAll { it.artifactId == dep.name }*.optional = true
}
gradleProject.providedDeps.each { dep ->
generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided'
generatedPom.dependencies.findAll { it.artifactId == dep.name }*.scope = 'provided'
}
// eliminate test-scoped dependencies (no need in maven central poms)