Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate POM files with non-wildcard excludes #21234

Merged
merged 2 commits into from Nov 4, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,6 +28,7 @@ import org.gradle.api.Task
import org.gradle.api.XmlProvider
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.ModuleVersionIdentifier
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.ResolvedArtifact
import org.gradle.api.artifacts.dsl.RepositoryHandler
Expand Down Expand Up @@ -294,7 +295,7 @@ class BuildPlugin implements Plugin<Project> {
* Returns a closure which can be used with a MavenPom for fixing problems with gradle generated poms.
*
* <ul>
* <li>Remove transitive dependencies (using wildcard exclusions, fixed in gradle 2.14)</li>
* <li>Remove transitive dependencies (using explicit exclusions to be compatible with Ivy)</li>
* <li>Set compile time deps back to compile from runtime (known issue with maven-publish plugin)
* </ul>
*/
Expand Down Expand Up @@ -334,10 +335,19 @@ class BuildPlugin implements Plugin<Project> {
continue
}

// we now know we have something to exclude, so add a wildcard exclusion element
Node exclusion = depNode.appendNode('exclusions').appendNode('exclusion')
exclusion.appendNode('groupId', '*')
exclusion.appendNode('artifactId', '*')
// we now know we have something to exclude, so add exclusions for all artifacts except the main one
Node exclusions = depNode.appendNode('exclusions')
for (ResolvedArtifact artifact : artifacts) {
ModuleVersionIdentifier moduleVersionIdentifier = artifact.moduleVersion.id;
String depGroupId = moduleVersionIdentifier.group
String depArtifactId = moduleVersionIdentifier.name
// add exclusions for all artifacts except the main one
if (depGroupId != groupId || depArtifactId != artifactId) {
Node exclusion = exclusions.appendNode('exclusion')
exclusion.appendNode('groupId', depGroupId)
exclusion.appendNode('artifactId', depArtifactId)
}
}
}
}
}
Expand Down