This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new a06e122  Set the --release version to Java 8, when bootstraping with 
higher versions of Java
a06e122 is described below

commit a06e1227a278408d2a7e13963f46d7a3ab48c9e5
Author: Jaikiran Pai <jaiki...@apache.org>
AuthorDate: Sun Aug 25 14:52:01 2019 +0530

    Set the --release version to Java 8, when bootstraping with higher versions 
of Java
---
 bootstrap.bat | 14 ++++++++++++--
 bootstrap.sh  | 19 +++++++++++++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/bootstrap.bat b/bootstrap.bat
index 4116444..3d7f396 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 2baf08f..c97abb3 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 \

Reply via email to