Build java_tools with jdk8

Since java11 was made the lang version in the .bazelrc, attempting to build with java8 leads to class version error. This keeps support for building with java8.

Closes #15747.

PiperOrigin-RevId: 457684595
Change-Id: Ieeaa0c1bb084ef36ffa25feaa7af0be161ee1516
diff --git a/src/upload_all_java_tools.sh b/src/upload_all_java_tools.sh
index fc6e35f..f2fdabc 100755
--- a/src/upload_all_java_tools.sh
+++ b/src/upload_all_java_tools.sh
@@ -51,13 +51,15 @@
 timestamp=$(date +%s)
 bazel_version=$(bazel info release | cut -d' ' -f2)
 
+JAVA_BUILD_OPTS="--tool_java_language_version=8 --java_language_version=8"
+
 # Passing the same commit_hash and timestamp to all targets to mark all the artifacts
 # uploaded on GCS with the same identifier.
 
-bazel build //src:java_tools_zip
+bazel build ${JAVA_BUILD_OPTS} //src:java_tools_zip
 zip_path=${PWD}/bazel-bin/src/java_tools.zip
 
-bazel build //src:java_tools_prebuilt_zip
+bazel build ${JAVA_BUILD_OPTS} //src:java_tools_prebuilt_zip
 prebuilt_zip_path=${PWD}/bazel-bin/src/java_tools_prebuilt.zip
 
 if [[ "$platform" == "windows" ]]; then
@@ -82,18 +84,18 @@
     done
 fi
 
-bazel run //src:upload_java_tools_prebuilt -- \
+bazel run ${JAVA_BUILD_OPTS} //src:upload_java_tools_prebuilt -- \
     --commit_hash ${commit_hash} \
     --timestamp ${timestamp} \
     --bazel_version ${bazel_version}
 
 if [[ "$platform" == "linux" ]]; then
-    bazel run //src:upload_java_tools -- \
+    bazel run ${JAVA_BUILD_OPTS} //src:upload_java_tools -- \
         --commit_hash ${commit_hash} \
         --timestamp ${timestamp} \
         --bazel_version ${bazel_version}
 
-    bazel run //src:upload_java_tools_dist -- \
+    bazel run ${JAVA_BUILD_OPTS} //src:upload_java_tools_dist -- \
         --commit_hash ${commit_hash} \
         --timestamp ${timestamp} \
         --bazel_version ${bazel_version}