From ce80278ab7aa96ae0fd528dbf4046b3a4633ddbd Mon Sep 17 00:00:00 2001 From: Weimin Yu Date: Mon, 10 Feb 2020 11:20:11 -0500 Subject: [PATCH] Make Gradle dependency cache shareable in GCB (#479) * Make Gradle dependency cache shareable in GCB Make Gradle put its caches in the source tree so that they can be preserved across steps. When left at their default location, caches are lost after each step. --- .gitignore | 1 + config/presubmits.py | 2 +- java_common.gradle | 1 + release/build_nomulus_for_env.sh | 7 +++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 17e3b6f81..5254bc9ca 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,7 @@ nomulus.iws !/gradle/wrapper/**/*.jar .gradle/ **/build +cloudbuild-caches/ node_modules/** /repos/ diff --git a/config/presubmits.py b/config/presubmits.py index 4559ea792..f5f6eef7d 100644 --- a/config/presubmits.py +++ b/config/presubmits.py @@ -22,7 +22,7 @@ import sys import re # We should never analyze any generated files -UNIVERSALLY_SKIPPED_PATTERNS = {"/build/", "/out/"} +UNIVERSALLY_SKIPPED_PATTERNS = {"/build/", "cloudbuild-caches", "/out/"} # We can't rely on CI to have the Enum package installed so we do this instead. FORBIDDEN = 1 REQUIRED = 2 diff --git a/java_common.gradle b/java_common.gradle index d77f39b8a..4d6fdd749 100644 --- a/java_common.gradle +++ b/java_common.gradle @@ -115,6 +115,7 @@ spotless { format 'misc', { clearSteps() target '**/*.gradle' + targetExclude '**/cloudbuild-caches/**' trimTrailingWhitespace() indentWithSpaces(2) endWithNewline() diff --git a/release/build_nomulus_for_env.sh b/release/build_nomulus_for_env.sh index 87e778dc6..fc82ef811 100755 --- a/release/build_nomulus_for_env.sh +++ b/release/build_nomulus_for_env.sh @@ -29,6 +29,13 @@ environment="$1" dest="$2" gcs_prefix="storage.googleapis.com/domain-registry-maven-repository" +# Let Gradle put its caches (dependency cache and build cache) in the source +# tree. This allows sharing of the caches between steps in a Cloud Build +# task. (See ./cloudbuild-nomulus.yaml, which calls this script in several +# steps). If left at their default location, the caches will be lost after +# each step. +export GRADLE_USER_HOME="./cloudbuild-caches" + if [ "${environment}" == tool ] then mkdir -p "${dest}"