Publishing - Remove POM Dependency Nodes


(David Harrigan) #1

Hi,

Gradle 2.0 Java 8u5

I have a requirement to publish a JAR that has an associated POM stripped of all dependencies. I’ve tried something like this:

publishing {
    publications {
        core(MavenPublication) {
            artifactId 'core'
            from components.java
            artifacts = [coreJar, coreSourcesJar]
        }
        model(MavenPublication) {
            artifactId 'model'
            from components.java
            artifacts = [modelJar]
            pom.withXml {
                asNode().dependencies.'*'.findAll() {
                    println it
                    //it.remove()
                }
            }
        }
    }
    repositories {
        maven {
            url "${repositoryUrl}/libs-${project.version.endsWith('-SNAPSHOT') ? 'snapshot' : 'release'}-local"
        }
    }
}

But it fails :frowning: Is there a way to do this in Gradle 2.0 (perhaps using a configuration)? I suppose as an extension to this, is there also a way to only include certain JARS (perhaps a custom configuration?)

Thank you.

-=david=-


(David Harrigan) #2

I guess a way around this is for the project which is importing the “model” jar dependency to stipulate “@jar” within the dependency block.

-=david=-