Gradle: maven publish generated pom, dependencies with scope runtime instead of compile
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 23 Jan 2017 06:10:22 +0000 (07:10 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 23 Jan 2017 06:10:22 +0000 (07:10 +0100)
https://discuss.gradle.org/t/maven-publish-plugin-generated-pom-making-dependency-scope-runtime/7494/13

SpringJava/Gradle/build.gradle

index be5d22e..1657670 100644 (file)
@@ -103,6 +103,16 @@ subprojects {
                 artifact javadocJar {
                     classifier 'javadoc'
                 }
+
+                pom.withXml {
+                    asNode().dependencies.'*'.findAll() {
+                        it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
+                            dep.name == it.artifactId.text()
+                        }
+                    }.each() {
+                        it.scope*.value = 'compile'
+                    }
+                }
             }
         }
         repositories {