makes checkLibVersions gradle 5 compatible

This commit is contained in:
Lars K.W. Gohlke 2018-11-29 23:26:51 +01:00 committed by AsamK
parent e809792467
commit 65390ef1d8

View file

@ -47,33 +47,35 @@ run {
// Find any 3rd party libraries which have released new versions
// to the central Maven repo since we last upgraded.
// http://daniel.gredler.net/2011/08/08/gradle-keeping-libraries-up-to-date/
task checkLibVersions << {
def checked = [:]
allprojects {
configurations.each { configuration ->
configuration.allDependencies.each { dependency ->
def version = dependency.version
if (!version.contains('SNAPSHOT') && !checked[dependency]) {
def group = dependency.group
def path = group.replace('.', '/')
def name = dependency.name
def url = "http://repo1.maven.org/maven2/$path/$name/maven-metadata.xml"
try {
def metadata = new XmlSlurper().parseText(url.toURL().text)
def versions = metadata.versioning.versions.version.collect { it.text() }
versions.removeAll { it.toLowerCase().contains('alpha') }
versions.removeAll { it.toLowerCase().contains('beta') }
versions.removeAll { it.toLowerCase().contains('rc') }
def newest = versions.max()
if (version != newest) {
println "$group:$name $version -> $newest"
task checkLibVersions {
doLast {
def checked = [:]
allprojects {
configurations.each { configuration ->
configuration.allDependencies.each { dependency ->
def version = dependency.version
if (!version.contains('SNAPSHOT') && !checked[dependency]) {
def group = dependency.group
def path = group.replace('.', '/')
def name = dependency.name
def url = "http://repo1.maven.org/maven2/$path/$name/maven-metadata.xml"
try {
def metadata = new XmlSlurper().parseText(url.toURL().text)
def versions = metadata.versioning.versions.version.collect { it.text() }
versions.removeAll { it.toLowerCase().contains('alpha') }
versions.removeAll { it.toLowerCase().contains('beta') }
versions.removeAll { it.toLowerCase().contains('rc') }
def newest = versions.max()
if (version != newest) {
println "$group:$name $version -> $newest"
}
} 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"
}
} 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
}
checked[dependency] = true
}
}
}