From d2bd022bd33fc8352d34aae04bd35426f4ca1cfd Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 26 May 2023 13:26:42 -0400 Subject: [PATCH 1/3] Do not re-download java dependencies every time. This moves java dependency download time from 500ms to 5ms after the initial download. If we get more dependencies, the savings should be even better. --- third_party/java_deps/set_up_java_deps.sh | 30 +++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/third_party/java_deps/set_up_java_deps.sh b/third_party/java_deps/set_up_java_deps.sh index d49ec170129494..2935cf6b1cb4c1 100755 --- a/third_party/java_deps/set_up_java_deps.sh +++ b/third_party/java_deps/set_up_java_deps.sh @@ -16,12 +16,26 @@ # limitations under the License. # +set -e + mkdir -p third_party/java_deps/artifacts -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar -o third_party/java_deps/artifacts/jsr305-3.0.2.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/org/json/json/20220924/json-20220924.jar -o third_party/java_deps/artifacts/json-20220924.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.8.10/kotlin-stdlib-1.8.10.jar -o third_party/java_deps/artifacts/kotlin-stdlib-1.8.10.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-test/1.8.10/kotlin-test-1.8.10.jar -o third_party/java_deps/artifacts/kotlin-test-1.8.10.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.22.0/protobuf-java-3.22.0.jar -o third_party/java_deps/artifacts/protobuf-java-3.22.0.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/com/google/truth/truth/1.1.3/truth-1.1.3.jar -o third_party/java_deps/artifacts/truth-1.1.3.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar -o third_party/java_deps/artifacts/junit-4.13.2.jar -curl --fail --location --silent --show-error https://repo1.maven.org/maven2/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar -o third_party/java_deps/artifacts/gson-2.9.1.jar + +function download_maven_jar() { + _MAVEN_PATH=$1 + _JAR_NAME=$2 + + if [ ! -f "third_party/java_deps/artifacts/${_JAR_NAME}" ]; then + curl --fail --location --silent --show-error \ + "https://repo1.maven.org/maven2/${_MAVEN_PATH}/${_JAR_NAME}" \ + -o "third_party/java_deps/artifacts/${_JAR_NAME}" + fi +} + +download_maven_jar "com/google/code/findbugs/jsr305/3.0.2" "jsr305-3.0.2.jar" +download_maven_jar "org/json/json/20220924" "json-20220924.jar" +download_maven_jar "org/jetbrains/kotlin/kotlin-stdlib/1.8.10" "kotlin-stdlib-1.8.10.jar" +download_maven_jar "org/jetbrains/kotlin/kotlin-test/1.8.10" "kotlin-test-1.8.10.jar" +download_maven_jar "com/google/protobuf/protobuf-java/3.22.0" "protobuf-java-3.22.0.jar" +download_maven_jar "com/google/truth/truth/1.1.3" "truth-1.1.3.jar" +download_maven_jar "junit/junit/4.13.2" "junit-4.13.2.jar" +download_maven_jar "com/google/code/gson/gson/2.9.1" "gson-2.9.1.jar" From 17a3aaf7c68bd50e26fd0bdcb8b2859aba159b1b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 26 May 2023 17:28:11 +0000 Subject: [PATCH 2/3] Restyled by shellharden --- third_party/java_deps/set_up_java_deps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/third_party/java_deps/set_up_java_deps.sh b/third_party/java_deps/set_up_java_deps.sh index 2935cf6b1cb4c1..2e03dcb325a622 100755 --- a/third_party/java_deps/set_up_java_deps.sh +++ b/third_party/java_deps/set_up_java_deps.sh @@ -24,10 +24,10 @@ function download_maven_jar() { _MAVEN_PATH=$1 _JAR_NAME=$2 - if [ ! -f "third_party/java_deps/artifacts/${_JAR_NAME}" ]; then + if [ ! -f "third_party/java_deps/artifacts/$_JAR_NAME" ]; then curl --fail --location --silent --show-error \ - "https://repo1.maven.org/maven2/${_MAVEN_PATH}/${_JAR_NAME}" \ - -o "third_party/java_deps/artifacts/${_JAR_NAME}" + "https://repo1.maven.org/maven2/$_MAVEN_PATH/$_JAR_NAME" \ + -o "third_party/java_deps/artifacts/$_JAR_NAME" fi } From 07d3ea134ad72d94d820cd4086b9fd100d19493b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 26 May 2023 17:28:12 +0000 Subject: [PATCH 3/3] Restyled by shfmt --- third_party/java_deps/set_up_java_deps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/java_deps/set_up_java_deps.sh b/third_party/java_deps/set_up_java_deps.sh index 2e03dcb325a622..ad7b27415e8a11 100755 --- a/third_party/java_deps/set_up_java_deps.sh +++ b/third_party/java_deps/set_up_java_deps.sh @@ -21,14 +21,14 @@ set -e mkdir -p third_party/java_deps/artifacts function download_maven_jar() { - _MAVEN_PATH=$1 - _JAR_NAME=$2 + _MAVEN_PATH=$1 + _JAR_NAME=$2 - if [ ! -f "third_party/java_deps/artifacts/$_JAR_NAME" ]; then - curl --fail --location --silent --show-error \ - "https://repo1.maven.org/maven2/$_MAVEN_PATH/$_JAR_NAME" \ - -o "third_party/java_deps/artifacts/$_JAR_NAME" - fi + if [ ! -f "third_party/java_deps/artifacts/$_JAR_NAME" ]; then + curl --fail --location --silent --show-error \ + "https://repo1.maven.org/maven2/$_MAVEN_PATH/$_JAR_NAME" \ + -o "third_party/java_deps/artifacts/$_JAR_NAME" + fi } download_maven_jar "com/google/code/findbugs/jsr305/3.0.2" "jsr305-3.0.2.jar"