Last active
August 29, 2015 14:01
-
-
Save behumble/851937a058eedfe39f73 to your computer and use it in GitHub Desktop.
duplicated AndroidManifest.xml@package finder
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
#!/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