maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ply...@apache.org
Subject cvs commit: jakarta-turbine-maven/src/bin maven.bat
Date Wed, 04 Dec 2002 19:16:58 GMT
plynch      2002/12/04 11:16:58

  Modified:    src/bin  maven.bat
  Log:
  o many improvements to the Windows batch file - a complete rewrite
  o issue MAVEN-135 ( MAVEN-129 ) resolved
  o add '@' to all REM statements so they don't print when MAVEN_BATCH_ECHO=on
  o ECHO --> MAVEN_BATCH_ECHO
  o PAUSE --> MAVEN_BATCH_PAUSE
  o all variables defined are reset to nothing upon exit of script for win 98/ME
  o detection for not set MAVEN_HOME and JAVA_HOME
  o detection for invalidly set MAVEN_HOME and JAVA_HOME
  o correctly determine a missing directory for MAVEN_HOME and JAVA_HOME
  o integrating latest changes from dIon's commits to resolve xml issues
  o added logic to call a user's %HOME%\mavenpre_rc.bat and mavenpost_rc.bat if they exist
  
  Revision  Changes    Path
  1.27      +154 -92   jakarta-turbine-maven/src/bin/maven.bat
  
  Index: maven.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/bin/maven.bat,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- maven.bat	2 Dec 2002 13:40:39 -0000	1.26
  +++ maven.bat	4 Dec 2002 19:16:57 -0000	1.27
  @@ -1,92 +1,154 @@
  -@echo off
  -@if not "%ECHO%" == ""  echo %ECHO%
  -
  -REM ----------------------------------------------------------------------------
  -REM Maven Windows Batch script
  -REM ----------------------------------------------------------------------------
  -
  -if "%JAVA_HOME%"  == "" goto error_java
  -
  -REM -- Set up command line args according to the OS present
  -
  -if not "%OS%"=="Windows_NT" goto win9x_start
  -:winNT_start
  -@setlocal
  -
  -REM -- Need to check if we are using the 4NT shell...
  -if "%eval[2+2]" == "4" goto setup_4NT
  -
  -REM -- On NT/2K grab all arguments at once
  -set MAVEN_CMD_LINE_ARGS=%*
  -If Not Exist "%MAVEN_HOME%" (
  -	echo MAVEN_HOME environment variable not found. Defaulting to "%ProgramFiles%\Maven"
  -    SET MAVEN_HOME=%ProgramFiles%\Maven
  -)
  -goto done_start
  -
  -:setup_4NT
  -set MAVEN_CMD_LINE_ARGS=%$
  -goto done_start
  -
  -:win9x_start
  -REM -- Slurp the command line arguments.  This loop allows for an unlimited
  -REM -- number of agruments (up to the command line limit, anyway).
  -
  -set MAVEN_CMD_LINE_ARGS=
  -
  -:setup_args
  -if %1a==a goto done_start
  -  set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
  -  shift
  -  goto setup_args
  -
  -:done_start
  -REM -- This label provides a place for the argument list loop to break out 
  -REM -- and for NT handling to skip to.
  -
  -REM -- Look for MAVEN_HOME, and make sure it exists
  -if "%MAVEN_HOME%" == "" goto ErrNoEnv
  -DIR "%MAVEN_HOME%" /AD | FIND /I /C "%MAVEN_HOME%" > nul
  -IF errorlevel 1 goto ErrNoDir
  -
  -SET MAVEN_SYS_OPTS=-Xmx160m
  -REM -- The following values are quoted as MAVEN_HOME might contain spaces
  -SET JAVA="%JAVA_HOME%\bin\java"
  -SET MAVEN_CLASSPATH="%MAVEN_HOME%\lib\forehead-1.0-beta-4.jar"
  -SET MAVEN_MAIN=com.werken.forehead.Forehead
  -SET MAVEN_ENDORSED="-Djava.endorsed.dirs=%JAVA_HOME%\lib\endorsed;%MAVEN_HOME%\lib\endorsed"
  -
  -REM %JAVA% -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
"-Dmaven.home=%MAVEN_HOME%" "-Dtools.jar=%JAVA_HOME%\lib\tools.jar" "-Dforehead.conf.file=%MAVEN_HOME%\bin\forehead.conf"
%MAVEN_SYS_OPTS% %MAVEN_OPTS% -classpath %MAVEN_CLASSPATH% %MAVEN_MAIN% %MAVEN_CMD_LINE_ARGS%
  -%JAVA% -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl "-Dmaven.home=%MAVEN_HOME%"
"-Dtools.jar=%JAVA_HOME%\lib\tools.jar" "-Dforehead.conf.file=%MAVEN_HOME%\bin\forehead.conf"
%MAVEN_ENDORSED% %MAVEN_SYS_OPTS% %MAVEN_OPTS% -classpath %MAVEN_CLASSPATH% %MAVEN_MAIN% %MAVEN_CMD_LINE_ARGS%
  -goto end
  -
  -:ErrNoEnv
  -
  -echo ERROR: MAVEN_HOME not found in your environment.
  -echo Please, set the MAVEN_HOME variable in your environment to match the
  -echo location of the Maven installation
  -
  -goto main_end
  -
  -:ErrNoDir
  -echo ERROR: File (%MAVEN_HOME%) MAVEN_HOME not found.
  -echo Please, set the MAVEN_HOME variable in your environment to match the
  -echo location of the Maven installation
  -goto main_end
  -
  -:error_java
  -
  -echo ERROR: JAVA_HOME not found in your environment.
  -echo Please, set the JAVA_HOME variable in your environment to match the
  -echo location of the Java installation
  -
  -goto main_end
  -
  -:end
  -
  -set MAVEN_CMD_LINE_ARGS=
  -if not "%OS%"=="Windows_NT" goto main_end
  -@endlocal
  -
  -:main_end
  -if not "%PAUSE%" == "" pause
  \ No newline at end of file
  +@REM ----------------------------------------------------------------------------
  +@REM Maven Start Up Batch script
  +@REM
  +@REM Required ENV vars:
  +@REM JAVA_HOME - location of a JDK home dir
  +@REM MAVEN_HOME - location of maven's installed home dir
  +@REM
  +@REM Optional ENV vars
  +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
  +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
  +@REM
  +@REM Utility rquirements:
  +@REM Windows' find.exe
  +@REM Windows' cmd.exe (NT) OR command.com ( 98 or ME )
  +@REM ----------------------------------------------------------------------------
  +
  +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
  +@echo off
  +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
  +@if "%MAVEN_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
  +
  +@REM Execute a user defined script before this one
  +:preExec
  +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
  +
  +@REM set local scope for the variables with windows NT shell
  +if "%OS%"=="Windows_NT" @setlocal
  +
  +@REM For Windows NT, use cmd.exe to execute the "CD" later
  +@REM For Win 98ME, use comand.com - if neither is found , default to use
  +@REM cmd.exe in the path and hope we'll hit a Win version of it
  +@REM FYI: Using command.com on Win NT causes "Parameter format not correct" error
  +set MAVEN_COMMAND_COM="cmd.exe"
  +if exist "%SystemRoot%\system32\cmd.exe" set MAVEN_COMMAND_COM="%SystemRoot%\system32\cmd.exe"
  +if exist "%SystemRoot%\command.com" set MAVEN_COMMAND_COM="%SystemRoot%\command.com"
  +
  +@REM Use explicit find.exe to prevent cygwin and others find.exe from being
  +@REM used instead - we use this to test dir existance in a cross-win-platform way
  +set MAVEN_FIND_EXE="find.exe"
  +if exist "%SystemRoot%\system32\find.exe" set MAVEN_FIND_EXE="%SystemRoot%\system32\find.exe"
  +if exist "%SystemRoot%\command\find.exe" set MAVEN_FIND_EXE="%SystemRoot%\command\find.exe"
  +
  +@REM ==== START VALIDATION ====
  +:checkSetJAVA_HOME
  +if not "%JAVA_HOME%" == "" goto checkValidJAVA_HOME
  +
  +:noJAVA_HOME
  +echo.
  +echo ERROR: JAVA_HOME not found in your environment.
  +echo Please set the JAVA_HOME variable in your environment to match the
  +echo location of your Java installation
  +echo.
  +goto end
  +
  +:checkValidJAVA_HOME
  +%MAVEN_COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %MAVEN_FIND_EXE% /I /C "%JAVA_HOME%"
>nul
  +if not errorlevel 1 goto checkSetMAVEN_HOME
  +
  +:invalidJAVA_HOME
  +echo.
  +echo ERROR: JAVA_HOME is set to an invalid directory.
  +echo JAVA_HOME = %JAVA_HOME%
  +echo Please set the JAVA_HOME variable in your environment to match the
  +echo location of your Java installation
  +echo.
  +goto end
  +
  +:checkSetMAVEN_HOME
  +if not "%MAVEN_HOME%"=="" goto checkValidMAVEN_HOME
  +
  +:noMAVEN_HOME
  +echo.
  +echo ERROR: MAVEN_HOME not found in your environment.
  +echo Please set the MAVEN_HOME variable in your environment to match the
  +echo location of the Maven installation
  +echo.
  +goto end
  +
  +:checkValidMAVEN_HOME
  +%MAVEN_COMMAND_COM% /C DIR "%MAVEN_HOME%" 2>&1 | %MAVEN_FIND_EXE% /I /C "%MAVEN_HOME%"
>nul
  +if not errorlevel 1 goto startInit
  +
  +:invalidMAVEN_HOME
  +echo.
  +echo ERROR: MAVEN_HOME is set to an invalid directory.
  +echo MAVEN_HOME = %MAVEN_HOME%
  +echo Please set the MAVEN_HOME variable in your environment to match the
  +echo location of the Maven installation
  +echo.
  +goto end
  +@REM ==== END VALIDATION ====
  +
  +:startInit
  +@REM Decide how to startup depending on the version of windows
  +@REM -- Win98ME
  +if NOT "%OS%"=="Windows_NT" goto prepareWin9xMEArgs
  +@REM -- 4NT shell
  +if "%eval[2+2]" == "4" goto prepare4NTArgs
  +@REM -- Regular WinNT shell
  +:prepareWinNTArgs
  +set MAVEN_CMD_LINE_ARGS=%*
  +goto doneInit
  +
  +@REM some special WinNT shell??
  +:prepare4NTArgs
  +set MAVEN_CMD_LINE_ARGS=%$
  +goto doneInit
  +
  +:prepareWin9xMEArgs
  +@REM Slurp the command line arguments.  This loop allows for an unlimited number
  +@REM of agruments (up to the command line limit, anyway).
  +set MAVEN_CMD_LINE_ARGS=
  +if %1a==a goto doneInit
  +set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
  +shift
  +goto setupWin9xMEArgs
  +
  +@REM Reaching here means variables are defined and arguments have been captured
  +:doneInit
  +SET MAVEN_DEFAULT_OPTS="-Xmx160m"
  +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
  +SET MAVEN_CLASSPATH="%MAVEN_HOME%\lib\forehead-1.0-beta-4.jar"
  +SET MAVEN_MAIN_CLASS="com.werken.forehead.Forehead"
  +SET MAVEN_ENDORSED="-Djava.endorsed.dirs=%JAVA_HOME%\lib\endorsed;%MAVEN_HOME%\lib\endorsed"
  +
  +@REM Start MAVEN
  +%MAVEN_JAVA_EXE% -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl "-Dmaven.home=%MAVEN_HOME%"
"-Dtools.jar=%JAVA_HOME%\lib\tools.jar" "-Dforehead.conf.file=%MAVEN_HOME%\bin\forehead.conf"
%MAVEN_ENDORSED% %MAVEN_DEFAULT_OPTS% %MAVEN_OPTS% -classpath %MAVEN_CLASSPATH% %MAVEN_MAIN_CLASS%
%MAVEN_CMD_LINE_ARGS%
  +@REM %MAVEN_JAVA_EXE% -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
"-Dmaven.home=%MAVEN_HOME%" "-Dtools.jar=%JAVA_HOME%\lib\tools.jar" "-Dforehead.conf.file=%MAVEN_HOME%\bin\forehead.conf"
%MAVEN_ENDORSED% %MAVEN_DEFAULT_OPTS% %MAVEN_OPTS% -classpath %MAVEN_CLASSPATH% %MAVEN_MAIN_CLASS%
%MAVEN_CMD_LINE_ARGS%
  +
  +:end
  +@REM set local scope for the variables with windows NT shell
  +if "%OS%"=="Windows_NT" goto endNT
  +
  +@REM For old DOS remove the set variables from ENV - we assume they were not set
  +@REM before we started - at least we don't leave any baggage around
  +set MAVEN_COMMAND_COM=
  +set MAVEN_FIND_EXE=
  +set MAVEN_DEFAULT_OPTS=
  +set MAVEN_JAVA_EXE=
  +set MAVEN_CLASSPATH=
  +set MAVEN_MAIN_CLASS=
  +set MAVEN_CMD_LINE_ARGS=
  +SET MAVEN_ENDORSED=
  +goto postExec
  +
  +:endNT
  +@endlocal
  +
  +:postExec
  +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
  +@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on'
  +if "%MAVEN_BATCH_PAUSE%" == "on" pause
  +
  +
  
  
  

Mime
View raw message