Publish task adds every dependency to the runtime scope in pom.xml

(Attila Kelemen) #1

When using the “maven-publish” plugin, compile time dependencies of a project will be added as “runtime” dependencies in the generated pom.xml. This is undesirable because it will break dependent projects relying on transitive dependencies.

(Peter Niederwieser) #2

It’s a known limitation of the new (and incubating) plugins, and will be fixed eventually.

(aadi4287) #3

Is there a workaround for this? I’m facing the same problem with generated ivy.xml using ivy-publish.

(Peter Niederwieser) #4

Either customize the generated POM, or use the ‘maven’ plugin.

(Max Bruchmann) #5

I found this workaround:

publishing {
    publications {
       pom.withXml {
      asNode().dependencies.'*'.findAll() {
       it.scope.text() == 'runtime' && yourOtherConfig.allDependencies.find { dep -> == it.artifactId.text()
      }.each() {
       it.scope*.value = 'your-other-scope'

assuming that you have an other configuration called “yourOtherConfig” like for example “compile”