summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeigh McCulloch <leigh@mcchouse.com>2019-02-18 01:47:57 +0000
committerGeorge Fraser <george@fivetran.com>2019-02-18 15:15:11 -0800
commite567bb0507f48f0558a056f4244b28b26731f0d2 (patch)
tree857df530701b36f98737fb925335cf7160c00d8e
parent2e2f574f4f4bbdaaec0debcdbc1a4552add36f15 (diff)
downloadjava-language-server-e567bb0507f48f0558a056f4244b28b26731f0d2.zip
Change to just check java version
-rwxr-xr-xscripts/benchmark.sh6
-rwxr-xr-xscripts/build.sh4
-rwxr-xr-xscripts/check_java_home.sh18
-rwxr-xr-xscripts/link_mac.sh11
-rwxr-xr-xscripts/link_windows.sh11
-rwxr-xr-xscripts/patch_gson.sh7
-rwxr-xr-xscripts/run_test.sh6
7 files changed, 32 insertions, 31 deletions
diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh
index bc896d1..57952d9 100755
--- a/scripts/benchmark.sh
+++ b/scripts/benchmark.sh
@@ -1,8 +1,8 @@
#!/bin/bash
-# Needed if you have a java version other than 11 as default
-JAVA_HOME=$(/usr/libexec/java_home -v 11)
+# Check JAVA_HOME points to correct java version
+./scripts/check_java_home.sh
# Compile the benchmark
mvn test-compile
@@ -14,4 +14,4 @@ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=scripts/cla
java -cp $(cat scripts/classpath.txt):target/classes:target/test-classes --illegal-access=warn org.openjdk.jmh.Main BenchmarkPruner
# Clean up
-rm scripts/classpath.txt \ No newline at end of file
+rm scripts/classpath.txt
diff --git a/scripts/build.sh b/scripts/build.sh
index 1768be3..f661948 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -2,8 +2,8 @@
set -e
-# Needed if you have a java version other than 11 as default
-JAVA_HOME=$(/usr/libexec/java_home -v 11)
+# Check JAVA_HOME points to correct java version
+./scripts/check_java_home.sh
# Needed once
npm install
diff --git a/scripts/check_java_home.sh b/scripts/check_java_home.sh
new file mode 100755
index 0000000..da6113c
--- /dev/null
+++ b/scripts/check_java_home.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Check the version of java pointed to by JAVA_HOME in version 11.
+
+set -e
+
+if [[ -z "${JAVA_HOME}" ]]; then
+ echo "error: JAVA_HOME must be set"
+ exit 1
+fi
+
+echo "JAVA_HOME is set to: $JAVA_HOME"
+
+java_version=$("$JAVA_HOME/bin/java" -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1/p;')
+echo "JAVA_HOME version is: $java_version"
+if [ "$java_version" -ne 11 ]; then
+ echo "error: JAVA_HOME must be set to a JDK version 11"
+ exit 1
+fi
diff --git a/scripts/link_mac.sh b/scripts/link_mac.sh
index e9982bf..976d221 100755
--- a/scripts/link_mac.sh
+++ b/scripts/link_mac.sh
@@ -3,15 +3,8 @@
set -e
-# Needed if you have a java version other than 11 as default
-echo "JAVA_HOME is set to: $JAVA_HOME"
-if [[ "$OSTYPE" == "linux-gnu" ]]; then
- JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
- echo "JAVA_HOME overrided to be: $JAVA_HOME"
-elif [[ "$OSTYPE" == "darwin"* ]]; then
- JAVA_HOME=$(/usr/libexec/java_home -v 11)
- echo "JAVA_HOME overrided to be: $JAVA_HOME"
-fi
+# Check JAVA_HOME points to correct java version
+./scripts/check_java_home.sh
# Compile sources
mvn compile
diff --git a/scripts/link_windows.sh b/scripts/link_windows.sh
index 0d16acb..3f9ff08 100755
--- a/scripts/link_windows.sh
+++ b/scripts/link_windows.sh
@@ -3,15 +3,8 @@
set -e
-# Needed if you have a java version other than 11 as default
-echo "JAVA_HOME is set to: $JAVA_HOME"
-if [[ "$OSTYPE" == "linux-gnu" ]]; then
- JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
- echo "JAVA_HOME overrided to be: $JAVA_HOME"
-elif [[ "$OSTYPE" == "darwin"* ]]; then
- JAVA_HOME=$(/usr/libexec/java_home -v 11)
- echo "JAVA_HOME overrided to be: $JAVA_HOME"
-fi
+# Check JAVA_HOME points to correct java version
+./scripts/check_java_home.sh
# Compile sources
mvn compile
diff --git a/scripts/patch_gson.sh b/scripts/patch_gson.sh
index 348f01f..7d40e29 100755
--- a/scripts/patch_gson.sh
+++ b/scripts/patch_gson.sh
@@ -5,11 +5,8 @@
set -e
-# Needed if you have a java version other than 11 as default
-# and used if java_home is available
-if [ -f /usr/libexec/java_home ] ; then
- JAVA_HOME=$(/usr/libexec/java_home -v 11)
-fi
+# Check JAVA_HOME points to java 11
+./scripts/check_java_home.sh
# Download Gson jar
cd modules
diff --git a/scripts/run_test.sh b/scripts/run_test.sh
index 896b250..f00b81d 100755
--- a/scripts/run_test.sh
+++ b/scripts/run_test.sh
@@ -2,7 +2,7 @@
set -e
-# Needed if you have a java version other than 11 as default
-JAVA_HOME=$(/usr/libexec/java_home -v 11)
+# Check JAVA_HOME points to correct java version
+./scripts/check_java_home.sh
-mvn test -Dtest=$1#$2 \ No newline at end of file
+mvn test -Dtest=$1#$2