Fix compilation error because of vague JDK version check in compile.sh
Fixes: https://github.com/bazelbuild/bazel/issues/2677
--
Change-Id: Ie8518530dfd9a7eed41c44230e59afbd5724544b
Reviewed-on: https://cr.bazel.build/9455
PiperOrigin-RevId: 150754975
MOS_MIGRATED_REVID=150754975
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 294b154..becd458 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -65,9 +65,15 @@
MSYS_DLLS=""
+function get_minor_java_version() {
+ get_java_version
+ java_minor_version=$(echo $JAVA_VERSION | sed -E 's/.+\.(.+)(\..*)?/\1/')
+ javac_minor_version=$(echo $JAVAC_VERSION | sed -E 's/.+\.(.+)(\..*)?/\1/')
+}
+
# Check that javac -version returns a upper version than $JAVA_VERSION.
-get_java_version
-[ ${JAVA_VERSION#*.} -le ${JAVAC_VERSION#*.} ] || \
+get_minor_java_version
+[ ${java_minor_version} -le ${javac_minor_version} ] || \
fail "JDK version (${JAVAC_VERSION}) is lower than ${JAVA_VERSION}, please set \$JAVA_HOME."
JAR="${JAVA_HOME}/bin/jar"