Disable bwc distribution caching in master branch (#46686)

This commit disables caching of BWC snapshot distributions in the "trunk" (aka master) branch.
Since the previous major release branches move quickly we rarely get cache hits for these 
tasks, and the artifacts themselves are very large. This means the overhead here is high and
savings basically zero. We conditionally disable task output caching in this scenario in CI to 
avoid excessive build cache overhead as well as causing too much turn in the cache itself which
would lead to lots of cache entry evictions.
This commit is contained in:
Mark Vieira 2019-09-18 11:51:44 -07:00
parent 02a5e153dc
commit 507d879b70
No known key found for this signature in database
GPG Key ID: CA947EF7E6D4B105
2 changed files with 8 additions and 1 deletions

View File

@ -95,6 +95,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
ext.set("gradleJavaVersion", Jvm.current().getJavaVersion());
ext.set("gitRevision", gitRevision(project.getRootProject().getRootDir()));
ext.set("buildDate", ZonedDateTime.now(ZoneOffset.UTC));
ext.set("isCi", System.getenv("JENKINS_URL") != null);
});
}

View File

@ -223,8 +223,14 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased
Task bwcTask = createRunBwcGradleTask(buildBwcTaskName(projectName)) {
inputs.file("${project.buildDir}/refspec")
outputs.files(projectArtifact)
outputs.cacheIf { true }
outputs.cacheIf("BWC distribution caching is disabled on 'master' branch") {
// Don't bother caching in 'master' since the BWC branches move too quickly to make this cost worthwhile
project.ext.isCi && System.getenv('GIT_BRANCH')?.endsWith("master") == false
}
args ":${projectDir.replace('/', ':')}:assemble"
if (project.gradle.startParameter.buildCacheEnabled) {
args "--build-cache"
}
doLast {
if (projectArtifact.exists() == false) {
throw new InvalidUserDataException("Building ${bwcVersion} didn't generate expected file ${projectArtifact}")