Created
September 21, 2014 02:10
-
-
Save mattyb149/eabe45e0dc09f4c80853 to your computer and use it in GitHub Desktop.
Find different versions of same JAR in two paths
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
commonLibs = [:] | |
leftLibs = [] | |
rightLibs = [] | |
if(args?.length > 1) { | |
new File(args[0]).eachFileRecurse { | |
fileName = (it.name - '.jar') | |
fileNameNoVersion = fileName[0..fileName.lastIndexOf('-')-1] | |
leftLibs += fileNameNoVersion | |
commonLibs.putAt(fileNameNoVersion, commonLibs[fileNameNoVersion] ? (commonLibs[fileNameNoVersion] + [1:fileName]) : [1:fileName]) | |
} | |
new File(args[1]).eachFileRecurse { | |
fileName = (it.name - '.jar') | |
fileNameNoVersion = fileName[0..fileName.lastIndexOf('-')-1] | |
rightLibs += fileNameNoVersion | |
commonLibs.putAt(fileNameNoVersion, commonLibs[fileNameNoVersion] ? (commonLibs[fileNameNoVersion] + [2:fileName]) : [2:fileName]) | |
} | |
leftLibs.intersect(rightLibs).each { lib -> | |
println "${commonLibs[lib]}" | |
} | |
} | |
else { | |
// print usage | |
println 'Usage: jardiff <path1> <path2>\nDisplays the JARs common to both paths (ignoring version) and the versions of those JARs in each path.' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment