Created
April 2, 2012 21:21
-
-
Save ConnorWGarvey/2287312 to your computer and use it in GitHub Desktop.
Convert pom dependencies to Gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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