Skip to content

Instantly share code, notes, and snippets.

@mattyb149
Created September 21, 2014 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyb149/eabe45e0dc09f4c80853 to your computer and use it in GitHub Desktop.
Save mattyb149/eabe45e0dc09f4c80853 to your computer and use it in GitHub Desktop.
Find different versions of same JAR in two paths
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