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

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.

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

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

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

I found this workaround: http://forums.gradle.org/gradle/topics/maven_publish_plugin_generated_pom_making_dependency_scope_runtime

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

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