Created
October 20, 2015 09:53
-
-
Save tszpinda/4f5d1b203c601da9f7d7 to your computer and use it in GitHub Desktop.
scanpom find dependancy
This file contains hidden or 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
def ant = new AntBuilder(); | |
def scanner = ant.fileScanner { | |
fileset(dir:'.') { | |
include(name:"**/pom.xml") | |
exclude(name:"**/target/") | |
} | |
} | |
def count = 0; | |
for (f in scanner) { | |
count++; | |
def root = new XmlSlurper().parse(f); | |
def dependancyArtifactId = 'servlet-api'; | |
if(dependsOn(root, dependancyArtifactId)) { | |
println "${root.artifactId} " | |
println " -> ${dependancyArtifactId}" | |
} | |
} | |
def dependsOn(root, artifactId) { | |
def dependsOn = false; | |
root.dependencies.each { | |
it.dependency.each { | |
if (it.artifactId == artifactId) { | |
dependsOn = true; | |
return; | |
} | |
} | |
} | |
return dependsOn; | |
} | |
println "total count: ${count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment