Skip to content

Commit

Permalink
Fix --release param check in bootstrap.bat
Browse files Browse the repository at this point in the history
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 <[email protected]>

This closes apache#205 pull request at github.com/apache/ant
  • Loading branch information
mataha authored and jaikiran committed Sep 17, 2023
1 parent bcff8d9 commit 5c89d9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ Martin Landers
Martin Poeschl
Martin van den Bemt
Martin von Gagern
Mateusz Kazimierczuk
Mathieu Champlon
Mathieu Peltier
Matt Albrecht
Expand Down
4 changes: 4 additions & 0 deletions WHATSNEW
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======================================
Expand Down
15 changes: 9 additions & 6 deletions bootstrap.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions contributors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 5c89d9e

Please sign in to comment.