summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaikiran <jaikiran@apache.org>2022-11-17 06:18:34 +0530
committerGitHub <noreply@github.com>2022-11-17 06:18:34 +0530
commit4b7965dc68dbbe1a4fd1634907de37fc2a109fb8 (patch)
treed8e5e10c0f80a9e936745a0dfede497cdc62176d
parentbbe6859b2f57a2c9dcb51e269527f3c18a74aa1d (diff)
parentc8f579577d381afa7ae594c38c094777fdc0c141 (diff)
downloadant-4b7965dc68dbbe1a4fd1634907de37fc2a109fb8.tar.gz
Merge pull request #195 from keithc-ca/version
Fix detection of java.specification.version
-rw-r--r--src/script/ant17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/script/ant b/src/script/ant
index cfeb2759f..ebc5e95ef 100644
--- a/src/script/ant
+++ b/src/script/ant
@@ -369,11 +369,18 @@ else
fi
fi
# Run "java -XshowSettings:properties" and check the output for "java.specification.version" value
-JAVA_SPEC_VERSION=$("$JAVACMD" -XshowSettings:properties 2>&1 | grep "java.specification.version = " | tr -d '[:space:]java.specification.version=')
-if [ "$JAVA_SPEC_VERSION" -ge 18 ]; then
- # set security manager property to allow calls to System.setSecurityManager() at runtime
- ANT_OPTS="$ANT_OPTS -Djava.security.manager=allow"
-fi
+JAVA_SPEC_VERSION=$("$JAVACMD" -XshowSettings:properties 2>&1 | sed -n -e 's/[[:space:]]//g' -e 's/^java\.specification\.version=//p')
+case "$JAVA_SPEC_VERSION" in
+ 1.*)
+ # Up to and including Java 8, versions are reported as 1.N.
+ ;;
+ *)
+ if [ "$JAVA_SPEC_VERSION" -ge 18 ]; then
+ # set security manager property to allow calls to System.setSecurityManager() at runtime
+ ANT_OPTS="$ANT_OPTS -Djava.security.manager=allow"
+ fi
+ ;;
+esac
ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" -Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\""
if $ant_exec_debug; then
# using printf to avoid echo line continuation and escape interpretation confusion