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 5c89d9e25 Fix `--release` param check in bootstrap.bat
5c89d9e25 is described below

commit 5c89d9e25e63c27a85c0c57acec8427ca1ac965e
Author: Mateusz Kazimierczuk <mataha@shimiko.download>
AuthorDate: Wed Sep 13 13:13:32 2023 +0200

    Fix `--release` param check in bootstrap.bat
    
    The following check will always fail silently due to batch `echo` always
    taking strings literally - including double quotes:
    
        echo "public class JavacVersionCheck {}" 
>%CLASSDIR%\JavacVersionCheck.java
        "%JAVAC%" --release 8 -d %CLASSDIR% %CLASSDIR%\JavacVersionCheck.java 
>nul 2>&1
    
    With the following error message:
    
        JavacVersionCheck.java:1: error: class, interface, or enum expected
        "public class JavacVersionCheck {}"
        ^
        1 error
    
    Even with that fixed, the next statement will crash and burn on systems
    that do not have Command Extensions enabled (e.g. invoked with `cmd /y`):
    
        IF %ERRORLEVEL% EQU 0 SET JAVAC_RELEASE_VERSION="--release 8"
    
    With the following error message:
    
        EQU was unexpected at this time.
    
    In order to accommodate that, those checks have been corrected.
    
    Signed-off-by: Mateusz Kazimierczuk <mataha@shimiko.download>
    
    This closes #205 pull request at github.com/apache/ant
---
 CONTRIBUTORS     |  1 +
 WHATSNEW         |  4 ++++
 bootstrap.bat    | 15 +++++++++------
 contributors.xml |  4 ++++
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index d55ea4472..660b9bef3 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -278,6 +278,7 @@ Martin Landers
 Martin Poeschl
 Martin van den Bemt
 Martin von Gagern
+Mateusz Kazimierczuk
 Mathieu Champlon
 Mathieu Peltier
 Matt Albrecht
diff --git a/WHATSNEW b/WHATSNEW
index cabeada74..c598d4485 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -16,6 +16,10 @@ Fixed bugs:
    could result in an unexpected failure. This has now been fixed.
    Bugzilla Report 67417
 
+ * Fixes an issue in bootstrap.bat when trying to detect if the "javac"
+   command in the JDK supports the "--release" option.
+   Github Pull Request #205
+
 
 Changes from Ant 1.10.13 TO Ant 1.10.14
 =======================================
diff --git a/bootstrap.bat b/bootstrap.bat
index 46f2f9f1d..14c06d59b 100755
--- a/bootstrap.bat
+++ b/bootstrap.bat
@@ -60,21 +60,24 @@ 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
+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"
+IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 SET JAVAC_RELEASE_VERSION=--release 8
 DEL %CLASSDIR%\JavacVersionCheck.java %CLASSDIR%\JavacVersionCheck.class >nul 
2>&1
 echo.
-IF %JAVAC_RELEASE_VERSION% == "" (
+IF "%JAVAC_RELEASE_VERSION%" == "" (
   echo ... Compiling Ant Classes
   "%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
 ) ELSE (
-  echo ... Compiling Ant Classes with %JAVAC_RELEASE_VERSION%
+  echo ... Compiling Ant Classes with "%JAVAC_RELEASE_VERSION%"
   "%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
+IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 goto build
+goto mainEnd
+
+:build
 
 echo.
 echo ... Copying Required Files
diff --git a/contributors.xml b/contributors.xml
index 42fd240a2..eb44cf58f 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -1155,6 +1155,10 @@
     <first>Martin</first>
     <last>von Gagern</last>
   </name>
+  <name>
+    <first>Mateusz</first>
+    <last>Kazimierczuk</last>
+  </name>
   <name>
     <first>Mathieu</first>
     <last>Champlon</last>

Reply via email to