Skip to content

Commit 4434252

Browse files
andy31415andreilitvinrestyled-commits
authored andcommitted
Do not re-download java dependencies every time. (#26887)
* 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. * Restyled by shellharden * Restyled by shfmt --------- Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent bf6fd3b commit 4434252

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

third_party/java_deps/set_up_java_deps.sh

+22-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,26 @@
1616
# limitations under the License.
1717
#
1818

19+
set -e
20+
1921
mkdir -p third_party/java_deps/artifacts
20-
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
21-
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
22-
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
23-
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
24-
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
25-
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
26-
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
27-
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
22+
23+
function download_maven_jar() {
24+
_MAVEN_PATH=$1
25+
_JAR_NAME=$2
26+
27+
if [ ! -f "third_party/java_deps/artifacts/$_JAR_NAME" ]; then
28+
curl --fail --location --silent --show-error \
29+
"https://repo1.maven.org/maven2/$_MAVEN_PATH/$_JAR_NAME" \
30+
-o "third_party/java_deps/artifacts/$_JAR_NAME"
31+
fi
32+
}
33+
34+
download_maven_jar "com/google/code/findbugs/jsr305/3.0.2" "jsr305-3.0.2.jar"
35+
download_maven_jar "org/json/json/20220924" "json-20220924.jar"
36+
download_maven_jar "org/jetbrains/kotlin/kotlin-stdlib/1.8.10" "kotlin-stdlib-1.8.10.jar"
37+
download_maven_jar "org/jetbrains/kotlin/kotlin-test/1.8.10" "kotlin-test-1.8.10.jar"
38+
download_maven_jar "com/google/protobuf/protobuf-java/3.22.0" "protobuf-java-3.22.0.jar"
39+
download_maven_jar "com/google/truth/truth/1.1.3" "truth-1.1.3.jar"
40+
download_maven_jar "junit/junit/4.13.2" "junit-4.13.2.jar"
41+
download_maven_jar "com/google/code/gson/gson/2.9.1" "gson-2.9.1.jar"

0 commit comments

Comments
 (0)