Gradle not including dependencies in published pom.xml

I was able to work around this by having the script add the dependencies to the pom directly using pom.withXml.

//The publication doesn't know about our dependencies, so we have to manually add them to the pom
pom.withXml {
    def dependenciesNode = asNode().appendNode('dependencies')

    //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
    configurations.compile.allDependencies.each {
        def dependencyNode = dependenciesNode.appendNode('dependency')
        dependencyNode.appendNode('groupId', it.group)
        dependencyNode.appendNode('artifactId', it.name)
        dependencyNode.appendNode('version', it.version)
    }
}

This works for my project, it may have unforeseen consequences in others.

Leave a Comment