Fix Gradle UP-TO-DATE checking for all tasks

The two checker tasks run quickly so don't gain much from UP-TO-DATE,
but it is convenient to not see them in the noise (checkUpperBoundDeps
in particular). Gradle only performs UP-TO-DATE checks (on the inputs)
if the task has both inputs and outputs defined.

The biggest saving was for distZip/distTar/shadowDistZip/shadowDistTar
which were using the same name for the non-shadow and shadow versions.
Thus the output file would always be out-of-date because it had been
rewritten and was invalid. This is worrisome because we could have
"randomly" been using the shadow Zip/Tar at times and the non-shadow
ones at others, although I think in practice the shadow tasks always run
last and so those are the files we'd see. Changing the classifier avoids
the colliding file names. These tasks took ~7 seconds, so incremental
builds are considerably shorter now.
This commit is contained in:
Eric Anderson 2022-07-08 13:51:44 -07:00
parent 57fe766d10
commit 9cd17ce3a7
3 changed files with 12 additions and 1 deletions

View File

@ -273,6 +273,8 @@ subprojects {
// Detect Maven Enforcer's dependencyConvergence failures. We only care
// for artifacts used as libraries by others with Maven.
tasks.register('checkUpperBoundDeps') {
inputs.files(configurations.runtimeClasspath).withNormalizer(ClasspathNormalizer)
outputs.file("${buildDir}/tmp/${name}") // Fake output for UP-TO-DATE checking
doLast {
requireUpperBoundDepsMatch(configurations.runtimeClasspath, project)
}

View File

@ -71,6 +71,14 @@ tasks.named("jar").configure {
archiveClassifier = 'original'
}
tasks.named("distZip").configure {
archiveClassifier = "original"
}
tasks.named("distTar").configure {
archiveClassifier = "original"
}
def xdsPrefixName = 'io.grpc.xds'
tasks.named("shadowJar").configure {
archiveClassifier = null

View File

@ -181,7 +181,8 @@ tasks.named("shadowJar").configure {
}
def checkPackageLeakage = tasks.register("checkPackageLeakage") {
dependsOn shadowJar
inputs.files(shadowJar).withNormalizer(CompileClasspathNormalizer)
outputs.file("${buildDir}/tmp/${name}") // Fake output for UP-TO-DATE checking
doLast {
def jarEntryPrefixName = prefixName.replaceAll('\\.', '/')
shadowJar.outputs.getFiles().each { jar ->