Skip to content

Instantly share code, notes, and snippets.

@jashatton
Created August 2, 2012 14:05
Show Gist options
  • Save jashatton/3237323 to your computer and use it in GitHub Desktop.
Save jashatton/3237323 to your computer and use it in GitHub Desktop.
A build.gradle script that reads Maven dependencies using XmlSlurper and applies them to the gradle dependencies.
apply plugin: 'java'
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
}
dependencies {
def pomXml = new XmlSlurper().parse('pom.xml')
def pomDependencies = pomXml.dependencies.dependency
pomDependencies.each { dependency ->
def dependencySpec = "${dependency.groupId}:${dependency.artifactId}:${dependency.version}"
if(dependency.scope == 'test') {
dependencies.add 'testCompile', dependencySpec
} else {
dependencies.add 'compile', dependencySpec
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment