Skip to content

Instantly share code, notes, and snippets.

@ConnorWGarvey
Created April 2, 2012 21:21
Show Gist options
  • Save ConnorWGarvey/2287312 to your computer and use it in GitHub Desktop.
Save ConnorWGarvey/2287312 to your computer and use it in GitHub Desktop.
Convert pom dependencies to Gradle
#! /usr/bin/env groovy
def project = new XmlSlurper().parse(new File('pom.xml'))
def versionNodes = project.properties.children().findAll { it.name().endsWith('.version') }
def versions = [:]
for (versionNode in versionNodes) {
versions[versionNode.name()] = versionNode.text()
}
for (dependency in project.dependencies.dependency) {
print " compile('${dependency.groupId.text()}:${dependency.artifactId.text()}:"
def version = dependency.version.text()
if (version.startsWith('${')) {
print versions[version[2..-2]]
}
else {
print version
}
print '\')'
if (dependency.exclusions.children().size() != 0) {
println ' {'
for (exclusion in dependency.exclusions.exclusion) {
println " exclude group:'${exclusion.groupId.text()}', module:'${exclusion.artifactId.text()}'"
}
print ' }'
}
println ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment