Skip to content

Commit 305c834

Browse files
committed
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.
1 parent 59638bc commit 305c834

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

buildSrc/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ if (project != rootProject) {
202202
}
203203
}
204204

205+
// Track reaper jar as a test input using runtime classpath normalization strategy
206+
tasks.withType(Test).configureEach {
207+
inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
208+
}
209+
210+
normalization {
211+
runtimeClasspath {
212+
// We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
213+
ignore('META-INF/reaper.jar')
214+
}
215+
}
216+
205217
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
206218
licenseHeaders.enabled = false
207219

0 commit comments

Comments
 (0)