Skip to content

Commit

Permalink
Fix Gradle UP-TO-DATE checking for all tasks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ejona86 committed Jul 11, 2022
1 parent 57fe766 commit 9cd17ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions interop-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion xds/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 9cd17ce

Please sign in to comment.