Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Created October 20, 2015 09:53
Show Gist options
  • Save tszpinda/4f5d1b203c601da9f7d7 to your computer and use it in GitHub Desktop.
Save tszpinda/4f5d1b203c601da9f7d7 to your computer and use it in GitHub Desktop.
scanpom find dependancy
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