mirror of https://github.com/grpc/grpc-java.git
build.gradle: Add checkForUpdates task
This commit is contained in:
parent
3f0e90d54e
commit
c16972c54a
66
build.gradle
66
build.gradle
|
|
@ -1,4 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
|
id 'java' // changes the behavior of TARGET_JVM_VERSION_ATTRIBUTE
|
||||||
|
|
||||||
id "com.google.osdetector" apply false
|
id "com.google.osdetector" apply false
|
||||||
id "me.champeau.gradle.japicmp" apply false
|
id "me.champeau.gradle.japicmp" apply false
|
||||||
id "net.ltgt.errorprone" apply false
|
id "net.ltgt.errorprone" apply false
|
||||||
|
|
@ -524,3 +526,67 @@ def requireUpperBoundDepsMatch(Configuration conf, Project project) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
|
||||||
|
def isAcceptableVersion(ModuleComponentIdentifier candidate) {
|
||||||
|
String group = candidate.group
|
||||||
|
String module = candidate.module
|
||||||
|
String version = candidate.version
|
||||||
|
if (group == 'com.google.guava')
|
||||||
|
return true
|
||||||
|
if (group == 'io.netty' && version.contains('Final'))
|
||||||
|
return true
|
||||||
|
if (module == 'android-api-level-19')
|
||||||
|
return true
|
||||||
|
return version ==~ /^[0-9]+(\.[0-9]+)+$/
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
checkForUpdates {
|
||||||
|
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
|
||||||
|
resolutionStrategy {
|
||||||
|
componentSelection {
|
||||||
|
all {
|
||||||
|
if (!isAcceptableVersion(it.candidate))
|
||||||
|
it.reject("Not stable version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks every dependency in the version catalog to see if there is a newer
|
||||||
|
// version available. The 'checkForUpdates' configuration restricts the
|
||||||
|
// versions considered.
|
||||||
|
tasks.register('checkForUpdates') {
|
||||||
|
doLast {
|
||||||
|
def updateConf = project.configurations.checkForUpdates
|
||||||
|
updateConf.setVisible(false)
|
||||||
|
updateConf.setTransitive(false)
|
||||||
|
def versionCatalog = project.extensions.getByType(VersionCatalogsExtension).named("libs")
|
||||||
|
versionCatalog.libraryAliases.each { name ->
|
||||||
|
def dep = versionCatalog.findLibrary(name).get().get()
|
||||||
|
|
||||||
|
def oldConf = updateConf.copy()
|
||||||
|
def oldDep = project.dependencies.create(
|
||||||
|
group: dep.group, name: dep.name, version: dep.versionConstraint, classifier: 'pom')
|
||||||
|
oldConf.dependencies.add(oldDep)
|
||||||
|
def oldResolved = oldConf.resolvedConfiguration.resolvedArtifacts.iterator().next()
|
||||||
|
|
||||||
|
def newConf = updateConf.copy()
|
||||||
|
def newDep = project.dependencies.create(
|
||||||
|
group: dep.group, name: dep.name, version: '+', classifier: 'pom')
|
||||||
|
newConf.dependencies.add(newDep)
|
||||||
|
def newResolved = newConf.resolvedConfiguration.resolvedArtifacts.iterator().next()
|
||||||
|
if (oldResolved != newResolved) {
|
||||||
|
def oldId = oldResolved.id.componentIdentifier
|
||||||
|
def newId = newResolved.id.componentIdentifier
|
||||||
|
println("${newId.group}:${newId.module} ${oldId.version} -> ${newId.version}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue