@@ -8,19 +8,25 @@ plugin_dir=$(pwd)
8
8
project_root=" $GAUGE_PROJECT_ROOT "
9
9
compile_dir=" $gauge_custom_compile_dir "
10
10
11
- javaCommand =java
12
- javacCommand =javac
11
+ JAVA_CMD =java
12
+ JAVAC_CMD =javac
13
13
14
14
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 } "
17
17
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 } "
20
20
fi
21
21
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
24
30
echo -e " This version of gauge-java plugin does not support Java versions < 1.9" ;
25
31
echo -e " Please upgrade your Java version or use a version of gauge-java <= v0.7.4"
26
32
exit 1;
@@ -77,7 +83,7 @@ function build_project() {
77
83
echo $( list_files) > $target_file
78
84
args=" -encoding UTF-8 -d ${default_build_dir} @${target_file} "
79
85
if [ ! -z " $( sed ' /^$/d' $target_file ) " ]; then
80
- $javacCommand -cp " $class_path " $args
86
+ $JAVAC_CMD -cp " $class_path " $args
81
87
fi
82
88
rm $target_file
83
89
}
@@ -127,12 +133,12 @@ function start() {
127
133
fi
128
134
target_file=" $TMPDIR$RANDOM -$RANDOM .txt"
129
135
echo " -cp \" ${class_path} \" ${args} com.thoughtworks.gauge.GaugeRuntime --start" > $target_file
130
- $javaCommand @$target_file
136
+ $JAVA_CMD @$target_file
131
137
}
132
138
133
139
function init() {
134
140
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
136
142
}
137
143
138
144
tasks=(init start)
0 commit comments