Skip to content

Commit 1112008

Browse files
authored
414 launcher fix (#415)
* fix version check of java, closes #414 Signed-off-by: sriv <[email protected]> * bumping version - 0.7.6 Signed-off-by: sriv <[email protected]>
1 parent b99d68c commit 1112008

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

bin/launcher.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ plugin_dir=$(pwd)
88
project_root="$GAUGE_PROJECT_ROOT"
99
compile_dir="$gauge_custom_compile_dir"
1010

11-
javaCommand=java
12-
javacCommand=javac
11+
JAVA_CMD=java
12+
JAVAC_CMD=javac
1313

1414
if [ ! -z "${gauge_java_home}" ]; then
15-
javaCommand="${gauge_java_home}/bin/${javaCommand}"
16-
javacCommand="${gauge_java_home}/bin/${javacCommand}"
15+
JAVA_CMD="${gauge_java_home}/bin/${JAVA_CMD}"
16+
JAVAC_CMD="${gauge_java_home}/bin/${JAVAC_CMD}"
1717
elif [ ! -z "${JAVA_HOME}" ]; then
18-
javaCommand="${JAVA_HOME}/bin/${javaCommand}"
19-
javacCommand="${JAVA_HOME}/bin/${javacCommand}"
18+
JAVA_CMD="${JAVA_HOME}/bin/${JAVA_CMD}"
19+
JAVAC_CMD="${JAVA_HOME}/bin/${JAVAC_CMD}"
2020
fi
2121

22-
version=$("$javaCommand" -version 2>&1 | awk -F '"' '/version/ {print $2}')
23-
if [[ "$version" < "1.9" ]]; then
22+
REQUIRED_MAJOR_VERSION=9 # minimum java version supported
23+
INSTALLED_JAVA_VERSION=$($JAVA_CMD -version 2>&1 | awk '/version [0-9]*/ {print $3;}')
24+
25+
# Remove double quotes, remove leading "1." if it exists and remove everything apart from the major version number.
26+
INSTALLED_MAJOR_VERSION=$(echo $INSTALLED_JAVA_VERSION | sed -e 's/"//g' -e 's/^1\.//' -e 's/\..*//')
27+
28+
if (( INSTALLED_MAJOR_VERSION < REQUIRED_MAJOR_VERSION ))
29+
then
2430
echo -e "This version of gauge-java plugin does not support Java versions < 1.9";
2531
echo -e "Please upgrade your Java version or use a version of gauge-java <= v0.7.4"
2632
exit 1;
@@ -77,7 +83,7 @@ function build_project() {
7783
echo $(list_files) > $target_file
7884
args="-encoding UTF-8 -d ${default_build_dir} @${target_file}"
7985
if [ ! -z "$(sed '/^$/d' $target_file)" ]; then
80-
$javacCommand -cp "$class_path" $args
86+
$JAVAC_CMD -cp "$class_path" $args
8187
fi
8288
rm $target_file
8389
}
@@ -127,12 +133,12 @@ function start() {
127133
fi
128134
target_file="$TMPDIR$RANDOM-$RANDOM.txt"
129135
echo "-cp \"${class_path}\" ${args} com.thoughtworks.gauge.GaugeRuntime --start" >$target_file
130-
$javaCommand @$target_file
136+
$JAVA_CMD @$target_file
131137
}
132138

133139
function init() {
134140
add_runner_in_classpath
135-
CLASSPATH="${class_path}" $javaCommands com.thoughtworks.gauge.GaugeRuntime --init
141+
CLASSPATH="${class_path}" $JAVA_CMDs com.thoughtworks.gauge.GaugeRuntime --init
136142
}
137143

138144
tasks=(init start)

java.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "java",
3-
"version": "0.7.5",
3+
"version": "0.7.6",
44
"description": "Java support for gauge",
55
"install": {
66
"windows": [],

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291

292292
<properties>
293293
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
294-
<projectVersion>0.7.5</projectVersion>
294+
<projectVersion>0.7.6</projectVersion>
295295
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
296296
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
297297
</properties>

0 commit comments

Comments
 (0)