Maven-publish plugin does not add exclusions in the generated POM


(Dimitar Dimitrov) #1

When the ‘maven-publish’ plugins generates the poms, it does not convert the Gradle excludes to Maven exclusions, so I have to do something like this:

dependencies {
    compile "org.codehaus.groovy:groovy:2.3.4"
    compile('com.aestasit.infrastructure.sshoogr:sshoogr:0.9.16') { exclude module: 'groovy-all' }
}
  ....
  publishing {
    publications {
        all(MavenPublication) {
            from components.java
            artifact sourceJar
              pom.withXml {
                asNode().dependencies.dependency.with {
                    find { it.artifactId.text() == 'groovy' }
                                .setValue('provided') // so @Grab won't fetch it
                      find { it.artifactId.text() == 'sshoogr' }
                                .appendNode('exclusions').appendNode('exclusion').with {
                                    appendNode('groupId', 'org.codehaus.groovy')
                                    appendNode('artifactId', 'groovy-all')
                                }
               }
            }
        }
    }
}

This is error-prone and can lead to diverging classpaths between Gradle tests and the actual usage of the artifact (in my case this is a scripting library that gets fetched via @Grab)


(Peter Niederwieser) #2

It’s a known limitation. As far as I know, it’s fixed in 2.1.