Check openjdk $VERSION before setting $JAVA_HOME 05/14105/1
authorAnil Belur <abelur@linuxfoundation.org>
Wed, 9 Jan 2019 02:14:44 +0000 (12:14 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Wed, 9 Jan 2019 02:28:49 +0000 (12:28 +1000)
The default version of openjdk installed is openjdk-8 which
is set through the Jenkins job.

For CentOS we are installing jdk-11 and jdk-10 under /opt. So
we need to check the version of openjdk for the job to pick up
the right version of JDK.

Issue: RELENG-1454
Change-Id: I19d77c509c90bca5fea1af53dacc35772c7ac939
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
shell/update-java-alternatives.sh

index 29f6d38..2214790 100644 (file)
 JAVA_ENV_FILE="/tmp/java.env"
 
 update-java-redhat() {
-    export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION: -1}.0-openjdk"
+    if [[ "${SET_JDK_VERSION: -2}" = "11" ]]; then
+        export JAVA_HOME="/opt/jdk-11"
+    elif [[ "${SET_JDK_VERSION: -2}" = "10" ]]; then
+        export JAVA_HOME="/opt/jdk-10.0.2"
+    else
+        export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION: -1}.0-openjdk"
+    fi
     sudo /usr/sbin/alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1
     sudo /usr/sbin/alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1
     sudo /usr/sbin/alternatives --install /usr/lib/jvm/java-openjdk java_sdk_openjdk "${JAVA_HOME}" 1