Skip to content

Instantly share code, notes, and snippets.

@aliencode
Created July 4, 2013 04:20
Show Gist options
  • Select an option

  • Save aliencode/5924907 to your computer and use it in GitHub Desktop.

Select an option

Save aliencode/5924907 to your computer and use it in GitHub Desktop.
Gradle检测所有依赖版本是否有更新
task '_check.libversions'(description: 'check all dependencys version!') << {
def checked = [:]
allprojects {
configurations.each { configuration ->
configuration.allDependencies.each { dependency ->
def version2 = dependency.version
if(version2!=null && !version2.contains('SNAPSHOT') && !checked[dependency]) {
def group = dependency.group
def name = dependency.name
def url = "http://search.maven.org/solrsearch/select?q=g:%22${group}%22%20a:%22${name}%22&wt=mxl"
try {
def metadata = new XmlSlurper().parseText(url.toURL().text)
def newest = metadata.result.doc.str[3].text()
if(version2 != newest) {
println url
println "$group:$name $version2 -> $newest"
println '=========================================='
}
} catch(FileNotFoundException e) {
logger.debug "Unable to download $url: $e.message"
} catch(org.xml.sax.SAXParseException e) {
logger.debug "Unable to parse $url: $e.message"
}
checked[dependency] = true
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment