Fix caching of build-tools project tests (#52848)

We embed the :reaper project jar in the build-tools jar so we can spawn
a reaper process at build runtime. Due to this, the jar technically
isn't part of the test runtime classpath, but for input snapshotting
purposes, we should be treating it as such. Instead, because it lives
in META-INF, Gradle treats it as a normal file, which in practice means
its hash changes on every build (timestamps, etc).

This commit changes our input snapshotting strategy such that instead
we explicitly add the jar as an input to any test tasks using Gradle's
runtime classpath normalization strategy (ignore timestamps, jar entry
order, etc) and ignore the file in META-INF. This ensures that we can
properly cache test results for build-tools, why still ensuring that
changes to the :reaper project trigger reexecution of tests.
This commit is contained in:
Mark Vieira 2020-02-26 13:55:49 -08:00
parent 59638bc405
commit 305c8342ac
No known key found for this signature in database
GPG Key ID: CA947EF7E6D4B105
1 changed files with 12 additions and 0 deletions

View File

@ -202,6 +202,18 @@ if (project != rootProject) {
}
}
// Track reaper jar as a test input using runtime classpath normalization strategy
tasks.withType(Test).configureEach {
inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
}
normalization {
runtimeClasspath {
// We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
ignore('META-INF/reaper.jar')
}
}
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
licenseHeaders.enabled = false