Browse Source

Add script to cache dependencies (#33726)

With the introduction of immutable workers into our CI, we now have a
problem where we would have to download dependencies on every single
build. To this end our infrastructure team has introduced the
possibility to download dependencies one time and then bake these into
the base immutable worker image. For this, we introduce our version of
this special script which runs a task that downloads all dependencies of
all configurations. With this script, our infrastructure team will be
rebuilding these images on an at-least daily basis. This helps us avoid
having to download the dependencies for every single build.
Jason Tedor 7 years ago
parent
commit
92a48fa6b8
2 changed files with 27 additions and 0 deletions
  1. 19 0
      .ci/packer_cache.sh
  2. 8 0
      build.gradle

+ 19 - 0
.ci/packer_cache.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+SCRIPT="$0"
+
+# SCRIPT might be an arbitrarily deep series of symbolic links; loop until we
+# have the concrete path
+while [ -h "$SCRIPT" ] ; do
+  ls=$(ls -ld "$SCRIPT")
+  # Drop everything prior to ->
+  link=$(expr "$ls" : '.*-> \(.*\)$')
+  if expr "$link" : '/.*' > /dev/null; then
+    SCRIPT="$link"
+  else
+    SCRIPT=$(dirname "$SCRIPT")/"$link"
+  fi
+done
+
+source $(dirname "${SCRIPT}")/java-versions.properties
+JAVA_HOME="${HOME}"/.java/${ES_BUILD_JAVA} ./gradlew resolveAllDependencies --parallel

+ 8 - 0
build.gradle

@@ -628,3 +628,11 @@ if (System.properties.get("build.compare") != null) {
     }
   }
 }
+
+allprojects {
+  task resolveAllDependencies {
+    doLast {
+      configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
+    }
+  }
+}