summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaikiran Pai <jaikiran@apache.org>2019-08-25 14:52:01 +0530
committerJaikiran Pai <jaikiran@apache.org>2019-08-25 14:52:01 +0530
commita06e1227a278408d2a7e13963f46d7a3ab48c9e5 (patch)
treeca49fe7faeaef52fdaab1ff0525790921477e247
parent5981e1bff1e095bf85ee4d6565bc0c7ff93f2bb6 (diff)
downloadant-a06e1227a278408d2a7e13963f46d7a3ab48c9e5.tar.gz
Set the --release version to Java 8, when bootstraping with higher versions of Java
-rwxr-xr-xbootstrap.bat14
-rwxr-xr-xbootstrap.sh19
2 files changed, 29 insertions, 4 deletions
diff --git a/bootstrap.bat b/bootstrap.bat
index 411644412..3d7f39646 100755
--- a/bootstrap.bat
+++ b/bootstrap.bat
@@ -61,10 +61,20 @@ if not "%OS%" == "Windows_NT" if exist %CLASSDIR%\nul deltree/y %CLASSDIR%
if not exist build\nul mkdir build
if not exist build\classes\nul mkdir build\classes
+rem Check if javac tool supports the --release param
+SET JAVAC_RELEASE_VERSION=""
+echo "public class JavacVersionCheck {}" > %CLASSDIR%\JavacVersionCheck.java
+"%JAVAC%" --release 8 -d %CLASSDIR% %CLASSDIR%\JavacVersionCheck.java >nul 2>&1
+IF %ERRORLEVEL% EQU 0 SET JAVAC_RELEASE_VERSION="--release 8"
+DEL %CLASSDIR%\JavacVersionCheck.java %CLASSDIR%\JavacVersionCheck.class >nul 2>&1
echo.
-echo ... Compiling Ant Classes
+IF "%JAVAC_RELEASE_VERSION%" == "" (
+ echo ... Compiling Ant Classes
+) ELSE (
+ echo ... Compiling Ant Classes with %JAVAC_RELEASE_VERSION%
+)
-"%JAVAC%" %BOOTJAVAC_OPTS% -d %CLASSDIR% %TOOLS%\bzip2\*.java %TOOLS%\tar\*.java %TOOLS%\zip\*.java %TOOLS%\ant\*.java %TOOLS%\ant\types\*.java %TOOLS%\ant\taskdefs\*.java %TOOLS%\ant\util\regexp\RegexpMatcher.java %TOOLS%\ant\util\regexp\RegexpMatcherFactory.java %TOOLS%\ant\taskdefs\condition\*.java %TOOLS%\ant\taskdefs\compilers\*.java %TOOLS%\ant\types\resources\*.java %TOOLS%\ant\property\*.java
+"%JAVAC%" %BOOTJAVAC_OPTS% -d %CLASSDIR% %JAVAC_RELEASE_VERSION% %TOOLS%\bzip2\*.java %TOOLS%\tar\*.java %TOOLS%\zip\*.java %TOOLS%\ant\*.java %TOOLS%\ant\types\*.java %TOOLS%\ant\taskdefs\*.java %TOOLS%\ant\util\regexp\RegexpMatcher.java %TOOLS%\ant\util\regexp\RegexpMatcherFactory.java %TOOLS%\ant\taskdefs\condition\*.java %TOOLS%\ant\taskdefs\compilers\*.java %TOOLS%\ant\types\resources\*.java %TOOLS%\ant\property\*.java
if ERRORLEVEL 1 goto mainend
diff --git a/bootstrap.sh b/bootstrap.sh
index 2baf08f81..c97abb328 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -127,9 +127,24 @@ mkdir -p build
mkdir -p ${CLASSDIR}
mkdir -p bin
-echo ... Compiling Ant Classes
+# Check if javac tool supports the --release param
+echo "public class JavacVersionCheck {}" > ${CLASSDIR}/JavacVersionCheck.java
+"${JAVAC}" --release 8 -d ${CLASSDIR} ${CLASSDIR}/JavacVersionCheck.java 1>&2 2>/dev/null
+ret=$?
+rm ${CLASSDIR}/JavacVersionCheck.java ${CLASSDIR}/JavacVersionCheck.class 1>&2 2>/dev/null
+JAVAC_RELEASE_VERSION=
+if [ $ret -eq 0 ]; then
+ # set --release to 8
+ JAVAC_RELEASE_VERSION="--release 8"
+fi
+if [ "${JAVAC_RELEASE_VERSION}" = "" ]; then
+ echo ... Compiling Ant Classes
+else
+ echo ... Compiling Ant Classes with ${JAVAC_RELEASE_VERSION}
+fi
-"${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
+"${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${JAVAC_RELEASE_VERSION} \
+ ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
${TOOLS}/ant/util/regexp/RegexpMatcher.java \
${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \
${TOOLS}/ant/property/*.java \