You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sb...@apache.org on 2002/08/16 17:31:45 UTC

cvs commit: jakarta-ant/src/script ant.bat antRun.bat lcp.bat

sbailliez    2002/08/16 08:31:45

  Modified:    src/script ant.bat antRun.bat lcp.bat
  Log:
  Clean up batch scripts with simplified syntax to avoid problems with some
  w2k boxes and 4nt.
  PR:11478, 11250
  Submitted by: Patrick Luby <pa...@sun.com>
  
  Revision  Changes    Path
  1.19      +29 -49    jakarta-ant/src/script/ant.bat
  
  Index: ant.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/script/ant.bat,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ant.bat	2 Apr 2002 07:49:08 -0000	1.18
  +++ ant.bat	16 Aug 2002 15:31:45 -0000	1.19
  @@ -5,48 +5,31 @@
   
   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%
   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
  -if %1a==a goto doneStart
  +if ""%1""=="""" goto doneStart
   set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
   shift
   goto setupArgs
  -
  -:doneStart
   rem This label provides a place for the argument list loop to break out 
   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
   if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive
  @@ -66,48 +49,45 @@
   goto checkJava
   
   :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
   
   :checkJava
  -set _JAVACMD=%JAVACMD%
   set LOCALCLASSPATH=%CLASSPATH%
   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   If build fails because sun.* classes could not be found
   echo   you will need to set the JAVA_HOME environment variable
   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
  -if not "%JIKESPATH%" == "" goto runAntWithJikes
  +if not "%JIKESPATH%"=="" goto runAntWithJikes
   
   :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
   
   :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
   set LOCALCLASSPATH=
   set _JAVACMD=
   set ANT_CMD_LINE_ARGS=
   
  -if not "%OS%"=="Windows_NT" goto mainEnd
  -:winNTend
  -@endlocal
  +if not "%OS%"=="Windows_NT" @endlocal
   
   :mainEnd
   if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
  
  
  
  1.5       +18 -10    jakarta-ant/src/script/antRun.bat
  
  Index: antRun.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/script/antRun.bat,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- antRun.bat	10 Jan 2002 14:18:42 -0000	1.4
  +++ antRun.bat	16 Aug 2002 15:31:45 -0000	1.5
  @@ -3,21 +3,29 @@
   REM   Copyright (c) 2001 The Apache Software Foundation.  All rights
   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
   
  -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
  -if ""%1 == "" goto runCommand
  -set PARAMS=%PARAMS% %1
  +if ""%1""=="""" goto runCommand
  +set ANT_RUN_CMD=%ANT_RUN_CMD% %1
   shift
   goto loop
   
   :runCommand
  -rem echo %ANT_RUN_CMD% %PARAMS%
  -%ANT_RUN_CMD% %PARAMS%
  +rem echo %ANT_RUN_CMD%
  +%ANT_RUN_CMD%
  +
  +if "%OS%"=="Windows_NT" @endlocal
   
  
  
  
  1.4       +6 -2      jakarta-ant/src/script/lcp.bat
  
  Index: lcp.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/script/lcp.bat,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- lcp.bat	10 Jan 2002 14:18:42 -0000	1.3
  +++ lcp.bat	16 Aug 2002 15:31:45 -0000	1.4
  @@ -2,11 +2,15 @@
   REM   reserved.
   
   set _CLASSPATHCOMPONENT=%1
  -:argCheck
  -if %2a==a goto gotAllArgs
  +if ""%1""=="""" goto gotAllArgs
   shift
  +
  +:argCheck
  +if ""%1""=="""" goto gotAllArgs
   set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
  +shift
   goto argCheck
  +
   :gotAllArgs
   set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH%
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>