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

**URL:** <https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888>\
**Category:** Old Forum Archive\
**Created:** [June 15, 2013, 7:19pm UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888 "2013-06-15T19:19:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Attila\_Kelemen](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/attila_kelemen/32/12083_2.png) [@Attila\_Kelemen](https://discuss.gradle.org/u/Attila_Kelemen)\
**Post date:** [June 15, 2013, 7:19pm UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888/1 "2013-06-15T19:19:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [June 16, 2013, 12:38am UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888/2 "2013-06-16T00:38:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Invisible\_Arrow](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@Invisible\_Arrow](https://discuss.gradle.org/u/Invisible_Arrow)\
**Post date:** [May 24, 2014, 6:34pm UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888/3 "2014-05-24T18:34:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 24, 2014, 6:48pm UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888/4 "2014-05-24T18:48:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Max\_Bruchmann](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/max_bruchmann/32/620_2.png) [@Max\_Bruchmann](https://discuss.gradle.org/u/Max_Bruchmann)\
**Post date:** [May 26, 2014, 9:08am UTC](https://discuss.gradle.org/t/publish-task-adds-every-dependency-to-the-runtime-scope-in-pom-xml/1888/5 "2014-05-26T09:08:00Z")

</div>

I found this workaround: [http://forums.gradle.org/gradle/topics/maven\_publish\_plugin\_generated\_pom\_making\_dependency\_scope\_runtime](http://forums.gradle.org/gradle/topics/maven_publish_plugin_generated_pom_making_dependency_scope_runtime)

```gradle
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”
