Created
October 31, 2012 20:50
-
-
Save saltnlight5/3989782 to your computer and use it in GitHub Desktop.
parsepom.xml
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
// 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