Browse Source

Clean up batch scripts with simplified syntax to avoid problems with some

w2k boxes and 4nt.
PR:11478, 11250
Submitted by: Patrick Luby <patrick.luby@sun.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273230 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
462f94f6c2
3 changed files with 53 additions and 61 deletions
  1. +29
    -49
      src/script/ant.bat
  2. +18
    -10
      src/script/antRun.bat
  3. +6
    -2
      src/script/lcp.bat

+ 29
- 49
src/script/ant.bat View File

@@ -5,48 +5,31 @@ REM reserved.


if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat" if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"


if not "%OS%"=="Windows_NT" goto win9xStart
:winNTStart
@setlocal
if "%OS%"=="Windows_NT" @setlocal


rem %~dp0 is name of current script under NT
set DEFAULT_ANT_HOME=%~dp0

rem : operator works similar to make : operator
set DEFAULT_ANT_HOME=%DEFAULT_ANT_HOME%\..
rem %~dp0 is expanded pathname of the current script under NT
set DEFAULT_ANT_HOME=%~dp0..


if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME% if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME%
set DEFAULT_ANT_HOME= set DEFAULT_ANT_HOME=


rem Need to check if we are using the 4NT shell...
if "%@eval[2+2]" == "4" goto setup4NT

rem On NT/2K grab all arguments at once
set ANT_CMD_LINE_ARGS=%*
goto doneStart

:setup4NT
set ANT_CMD_LINE_ARGS=%$
goto doneStart

:win9xStart
rem Slurp the command line arguments. This loop allows for an unlimited number of
rem agruments (up to the command line limit, anyway).

set ANT_CMD_LINE_ARGS=

rem Slurp the command line arguments. This loop allows for an unlimited number
rem of arguments (up to the command line limit, anyway).
set ANT_CMD_LINE_ARGS=%1
if ""%1""=="""" goto doneStart
shift
:setupArgs :setupArgs
if %1a==a goto doneStart
if ""%1""=="""" goto doneStart
set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
shift shift
goto setupArgs goto setupArgs

:doneStart
rem This label provides a place for the argument list loop to break out rem This label provides a place for the argument list loop to break out
rem and for NT handling to skip to. rem and for NT handling to skip to.
:doneStart


rem find ANT_HOME
if not "%ANT_HOME%"=="" goto checkJava
rem find ANT_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
if exist "%ANT_HOME%" goto checkJava


rem check for ant in Program Files on system drive rem check for ant in Program Files on system drive
if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive
@@ -66,48 +49,45 @@ set ANT_HOME=C:\ant
goto checkJava goto checkJava


:noAntHome :noAntHome
echo ANT_HOME is not set and ant could not be located. Please set ANT_HOME.
echo ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
goto end goto end


:checkJava :checkJava
set _JAVACMD=%JAVACMD%
set LOCALCLASSPATH=%CLASSPATH% set LOCALCLASSPATH=%CLASSPATH%
for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i


if "%JAVA_HOME%" == "" goto noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java
if not exist "%_JAVACMD%.exe" echo Error: "%_JAVACMD%.exe" not found - check JAVA_HOME && goto end
if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\tools.jar
if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\classes.zip
goto checkJikes

:noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=java
echo.
if exist "%JAVA_HOME%\bin\java.exe" goto gotJava
echo
echo Warning: JAVA_HOME environment variable is not set. echo Warning: JAVA_HOME environment variable is not set.
echo If build fails because sun.* classes could not be found echo If build fails because sun.* classes could not be found
echo you will need to set the JAVA_HOME environment variable echo you will need to set the JAVA_HOME environment variable
echo to the installation directory of java. echo to the installation directory of java.
echo.
echo

:gotJava
set _JAVACMD=%JAVA_HOME%\bin\java.exe
if exist "%_JAVACMD%" goto checkJikes
set _JAVACMD=java.exe
if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\tools.jar
if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\classes.zip


:checkJikes :checkJikes
if not "%JIKESPATH%" == "" goto runAntWithJikes
if not "%JIKESPATH%"=="" goto runAntWithJikes


:runAnt :runAnt
"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
goto end goto end


:runAntWithJikes :runAntWithJikes
"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" -Djikes.class.path="%JIKESPATH%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
goto end


:end :end
set LOCALCLASSPATH= set LOCALCLASSPATH=
set _JAVACMD= set _JAVACMD=
set ANT_CMD_LINE_ARGS= set ANT_CMD_LINE_ARGS=


if not "%OS%"=="Windows_NT" goto mainEnd
:winNTend
@endlocal
if not "%OS%"=="Windows_NT" @endlocal


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


+ 18
- 10
src/script/antRun.bat View File

@@ -3,21 +3,29 @@
REM Copyright (c) 2001 The Apache Software Foundation. All rights REM Copyright (c) 2001 The Apache Software Foundation. All rights
REM reserved. REM reserved.


rem Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
cd %1
%1\
set ANT_RUN_CMD=%2
shift
if "%OS%"=="Windows_NT" @setlocal

if ""%1""=="""" goto runCommand

rem Change drive and directory to %1
if "%OS%"=="Windows_NT" cd /d ""%1""
if not "%OS%"=="Windows_NT" cd ""%1""
shift shift


set PARAMS=
rem Slurp the command line arguments. This loop allows for an unlimited number
rem of agruments (up to the command line limit, anyway).
set ANT_RUN_CMD=%1
if ""%1""=="""" goto runCommand
shift
:loop :loop
if ""%1 == "" goto runCommand
set PARAMS=%PARAMS% %1
if ""%1""=="""" goto runCommand
set ANT_RUN_CMD=%ANT_RUN_CMD% %1
shift shift
goto loop goto loop


:runCommand :runCommand
rem echo %ANT_RUN_CMD% %PARAMS%
%ANT_RUN_CMD% %PARAMS%
rem echo %ANT_RUN_CMD%
%ANT_RUN_CMD%

if "%OS%"=="Windows_NT" @endlocal



+ 6
- 2
src/script/lcp.bat View File

@@ -2,11 +2,15 @@ REM Copyright (c) 2001 The Apache Software Foundation. All rights
REM reserved. REM reserved.


set _CLASSPATHCOMPONENT=%1 set _CLASSPATHCOMPONENT=%1
:argCheck
if %2a==a goto gotAllArgs
if ""%1""=="""" goto gotAllArgs
shift shift

:argCheck
if ""%1""=="""" goto gotAllArgs
set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1 set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
shift
goto argCheck goto argCheck

:gotAllArgs :gotAllArgs
set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH% set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH%



Loading…
Cancel
Save