Browse Source

Fix for Bugzilla 13655. Thanks to Simon Law. Proper return code for ant.bat

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@354209 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 19 years ago
parent
commit
596831cb7f
5 changed files with 62 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +2
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +8
    -1
      docs/manual/running.html
  5. +47
    -0
      src/script/ant.bat

+ 1
- 0
CONTRIBUTORS View File

@@ -204,6 +204,7 @@ Sean Egan
Sean P. Kane
Shiraz Kanga
Sebastian Kantha
Simon Law
Stefan Bodewig
Stefano Mazzocchi
Stephane Bailliez


+ 2
- 0
WHATSNEW View File

@@ -166,6 +166,8 @@ Fixed bugs:
* PropertySet API setMapper(...) didn't properly set up the Mapper.
Bugzilla report 37760.

* Proper return code for ant.bat. Bugzilla report 13655.

Other changes:
--------------
* New task <manifestclasspath> converts a path into a property


+ 4
- 0
contributors.xml View File

@@ -837,6 +837,10 @@
<first>Sebastian</first>
<last>Kantha</last>
</name>
<name>
<first>Simon</first>
<last>Law</last>
</name>
<name>
<first>Stefan</first>
<last>Bodewig</last>


+ 8
- 1
docs/manual/running.html View File

@@ -445,7 +445,14 @@ very good reason to use another prefix. Accordingly, please avoid using
properties that begin with these prefixes. This protects you from future
Ant releases breaking your build file.
</p>

<h3>return code</h3>
<p>the ant start up scripts (in their Windows and Unix version) return
the return code of the java program. So a successful build returns 0,
failed builds return other values.
</p>
<p>Under Windows95 and 98, a special environment variable ANT_ERROR will be set
by the script ant.bat, because it is not possible to exit the script with a
specific errorlevel.</p>

<h2><a name="cygwin">Cygwin Users</a></h2>
<p>The Unix launch script that come with Ant works correctly with Cygwin. You


+ 47
- 0
src/script/ant.bat View File

@@ -92,14 +92,23 @@ if not "%JIKESPATH%"=="" goto runAntWithJikes
if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath
if not "%CLASSPATH%"=="" goto runAntWithClasspath
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
rem Check the error code of the Ant build
if not "%OS%"=="Windows_NT" goto onError
set ANT_ERROR=%ERRORLEVEL%
goto end

:runAntNoClasspath
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
rem Check the error code of the Ant build
if not "%OS%"=="Windows_NT" goto onError
set ANT_ERROR=%ERRORLEVEL%
goto end

:runAntWithClasspath
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
rem Check the error code of the Ant build
if not "%OS%"=="Windows_NT" goto onError
set ANT_ERROR=%ERRORLEVEL%
goto end

:runAntWithJikes
@@ -108,19 +117,57 @@ if not "%CLASSPATH%"=="" goto runAntWithJikesAndClasspath

:runAntWithJikesNoClasspath
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
rem Check the error code of the Ant build
if not "%OS%"=="Windows_NT" goto onError
set ANT_ERROR=%ERRORLEVEL%
goto end

:runAntWithJikesAndClasspath
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
rem Check the error code of the Ant build
if not "%OS%"=="Windows_NT" goto onError
set ANT_ERROR=%ERRORLEVEL%
goto end

:onError
rem Windows 9x way of checking the error code. It matches via brute force.
for %%i in (1 10 100) do set err%%i=
for %%i in (0 1 2) do if errorlevel %%i00 set err100=%%i
if %err100%==2 goto onError200
if %err100%==0 set err100=
for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%%i0 set err10=%%i
if "%err100%"=="" if %err10%==0 set err10=
:onError1
for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%err10%%%i set err1=%%i
goto onErrorEnd
:onError200
for %%i in (0 1 2 3 4 5) do if errorlevel 2%%i0 set err10=%%i
if err10==5 for %%i in (0 1 2 3 4 5) do if errorlevel 25%%i set err1=%%i
if not err10==5 goto onError1
:onErrorEnd
set ANT_ERROR=%err100%%err10%%err1%
for %%i in (1 10 100) do set err%%i=

:end
set _JAVACMD=
set ANT_CMD_LINE_ARGS=

rem Set the return code if we are not in NT. We can only set
rem a value of 1, but it's better than nothing.
if not "%OS%"=="Windows_NT" if "%ANT_ERROR%"=="" set ANT_ERROR=255
if not "%OS%"=="Windows_NT" if "%ANT_ERROR%"=="0" goto quit
if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
rem Set the ERRORLEVEL if we are running NT.
if "%OS%"=="Windows_NT" if "%ANT_ERROR%"=="" set ANT_ERROR=255
if "%OS%"=="Windows_NT" if not %ANT_ERROR%==0 color 00
goto quit

rem If there were no errors, we run the post script.
if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal

:mainEnd
if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"

:quit


Loading…
Cancel
Save