Skip to content

Instantly share code, notes, and snippets.

@saltnlight5
Created October 31, 2012 20:50
Show Gist options
  • Save saltnlight5/3989782 to your computer and use it in GitHub Desktop.
Save saltnlight5/3989782 to your computer and use it in GitHub Desktop.
parsepom.xml
// Parse pom.xml and print all dependency elements in single line for gradle use instead.
// Zemian Deng 11/1/2012
depMap = [:].withDefault{ [] }
project = new XmlParser().parse("pom.xml")
project.dependencies[0].each{ dependency ->
line = "'" + dependency.groupId.text() + ":" +
dependency.artifactId.text() + ":" +
dependency.version.text() + "'"
scope = dependency.scope.text() ?: 'compile'
depMap[scope] << line
}
depMap.entrySet().sort{ it.key }.each{ entry ->
scope = entry.key
depList = entry.value
println scope + "("
println depList.collect{ ' ' + it }.join(",\n")
println ")"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment