Skip to content

Commit

Permalink
Do not re-download java dependencies every time. (#26887)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored May 27, 2023
1 parent 5a6b771 commit b3adaa6
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions third_party/java_deps/set_up_java_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit b3adaa6

Please sign in to comment.