Skip to content

Instantly share code, notes, and snippets.

@behumble
Last active August 29, 2015 14:01
Show Gist options
  • Save behumble/851937a058eedfe39f73 to your computer and use it in GitHub Desktop.
Save behumble/851937a058eedfe39f73 to your computer and use it in GitHub Desktop.
duplicated AndroidManifest.xml@package finder
#!/usr/bin/env groovy
String extractPackageName(File manifestFile) {
return new XmlSlurper().parse(manifestFile).@package
}
void listDuplicates() {
for( e in packageToFiles ) {
files = e.value
if(files.size>1) {
dispList = files.parentFile.name
println "$e.key : $dispList"
}
}
}
workingDir = new File(".")
println "Android package name duplicate finder [$workingDir.canonicalPath]"
println "----"
packageToFiles = [:]
workingDir.eachDirMatch(~/.*-lib/) {
manifestFile = new File(it, "AndroidManifest.xml")
if(manifestFile.isFile()) {
pkgName = extractPackageName(manifestFile)
files = packageToFiles[pkgName]
if(files==null) {
files = []
packageToFiles[pkgName] = files
}
files.add( manifestFile )
}
}
listDuplicates()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment