[MNG-3354] & [MNG-3296] Patching Windows batch files for maven, to improve support for Windows+Novell integration, and to handle the end of winnt's local scope with the errorlevel preserved.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@619106 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-02-06 19:03:43 +00:00
parent 04ad40121c
commit 1611fcfbdf
2 changed files with 57 additions and 8 deletions

View File

@ -37,6 +37,9 @@
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%)
@REM Execute a user defined script before this one
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
@ -44,6 +47,7 @@ set ERROR_CODE=0
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
@ -70,6 +74,7 @@ goto error
if not "%M2_HOME%"=="" goto valMHome
if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0\..
if "%OS%"=="WINNT" SET M2_HOME=%~dp0\..
if not "%M2_HOME%"=="" goto valMHome
echo.
@ -101,11 +106,16 @@ goto error
:init
@REM Decide how to startup depending on the version of windows
@REM -- Windows NT with Novell Login
if "%OS%"=="WINNT" goto WinNTNovell
@REM -- Win98ME
if NOT "%OS%"=="Windows_NT" goto Win9xArg
:WinNTNovell
@REM -- 4NT shell
if "%eval[2+2]" == "4" goto 4NTArgs
if "%@eval[2+2]" == "4" goto 4NTArgs
@REM -- Regular WinNT shell
set MAVEN_CMD_LINE_ARGS=%*
@ -130,19 +140,33 @@ goto Win9xApp
:endInit
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTCWJars
@REM -- Regular WinNT shell
for %%i in ("%M2_HOME%"\boot\classworlds-*) do set CLASSWORLDS_JAR="%%i"
goto runm2
@REM The 4NT Shell from jp software
:4NTCWJars
for %%i in ("%M2_HOME%\boot\classworlds-*") do set CLASSWORLDS_JAR="%%i"
goto runm2
@REM Start MAVEN2
for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.plexus.classworlds.launcher.Launcher %MAVEN_CMD_LINE_ARGS%
:runm2
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
:error
if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal
set ERROR_CODE=1
:end
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT
if "%OS%"=="WINNT" 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
@ -151,7 +175,7 @@ set MAVEN_CMD_LINE_ARGS=
goto postExec
:endNT
@endlocal
@endlocal & set ERROR_CODE=%ERROR_CODE%
:postExec
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"

View File

@ -40,6 +40,9 @@ set INT_MAVEN_OPTS=%MAVEN_OPTS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%)
@REM Execute a user defined script before this one
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
@ -47,6 +50,7 @@ set ERROR_CODE=0
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
@ -73,6 +77,7 @@ goto error
if not "%M2_HOME%"=="" goto valMHome
if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0\..
if "%OS%"=="WINNT" SET M2_HOME=%~dp0\..
if not "%M2_HOME%"=="" goto valMHome
echo.
@ -104,11 +109,16 @@ goto error
:init
@REM Decide how to startup depending on the version of windows
@REM -- Windows NT with Novell Login
if "%OS%"=="WINNT" goto WinNTNovell
@REM -- Win98ME
if NOT "%OS%"=="Windows_NT" goto Win9xArg
:WinNTNovell
@REM -- 4NT shell
if "%eval[2+2]" == "4" goto 4NTArgs
if "%@eval[2+2]" == "4" goto 4NTArgs
@REM -- Regular WinNT shell
set MAVEN_CMD_LINE_ARGS=%*
@ -133,19 +143,34 @@ goto Win9xApp
:endInit
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTCWJars
@REM -- Regular WinNT shell
for %%i in ("%M2_HOME%"\boot\classworlds-*) do set CLASSWORLDS_JAR="%%i"
goto runm2
@REM The 4NT Shell from jp software
:4NTCWJars
for %%i in ("%M2_HOME%\boot\classworlds-*") do set CLASSWORLDS_JAR="%%i"
goto runm2
@REM Start MAVEN2
for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
%MAVEN_JAVA_EXE% %INT_MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.plexus.classworlds.launcher.Launcher %MAVEN_CMD_LINE_ARGS%
:runm2
%MAVEN_JAVA_EXE% %INT_MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
:error
if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal
set ERROR_CODE=1
:end
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT
if "%OS%"=="WINNT" 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
@ -154,7 +179,7 @@ set MAVEN_CMD_LINE_ARGS=
goto postExec
:endNT
@endlocal
@endlocal & set ERROR_CODE=%ERROR_CODE%
:postExec
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"