From c6faf8dd65587c3ea6d79ccf48e25bb7b90e18df Mon Sep 17 00:00:00 2001 From: Andreas Gudian Date: Sat, 28 Feb 2015 15:50:58 +0100 Subject: [PATCH] MNG-5776 Drop support for Win9x in mvn launch scripts for Windows, rename .bat to .cmd, remove duplicate code from mvnDebug.cmd --- apache-maven/README.txt | 6 +- apache-maven/src/bin/mvn.bat | 239 ------------------ .../src/bin/{mvnDebug.bat => mvn.cmd} | 101 ++------ apache-maven/src/bin/mvnDebug.cmd | 31 +++ 4 files changed, 52 insertions(+), 325 deletions(-) delete mode 100644 apache-maven/src/bin/mvn.bat rename apache-maven/src/bin/{mvnDebug.bat => mvn.cmd} (68%) create mode 100644 apache-maven/src/bin/mvnDebug.cmd diff --git a/apache-maven/README.txt b/apache-maven/README.txt index 668fb31a82..448ef6e392 100644 --- a/apache-maven/README.txt +++ b/apache-maven/README.txt @@ -31,8 +31,10 @@ that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. Operating System: - No minimum requirement. Start up scripts are included as shell scripts and Windows - batch files. + Windows: + Windows 2000 or above. + Unix based systems (Linux, Solaris and Mac OS X) and others: + No minimum requirement. Installing Maven ---------------- diff --git a/apache-maven/src/bin/mvn.bat b/apache-maven/src/bin/mvn.bat deleted file mode 100644 index 546842aae5..0000000000 --- a/apache-maven/src/bin/mvn.bat +++ /dev/null @@ -1,239 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@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 MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@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_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 not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -:skipRcPre - -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 - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:chkMHome -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. -echo Error: M2_HOME not found in your environment. >&2 -echo Please set the M2_HOME variable in your environment to match the >&2 -echo location of the Maven installation. >&2 -echo. -goto error - -:valMHome - -:stripMHome -if not "_%M2_HOME:~-1%"=="_\" goto checkMBat -set "M2_HOME=%M2_HOME:~0,-1%" -goto stripMHome - -:checkMBat -if exist "%M2_HOME%\bin\mvn.bat" goto init - -echo. -echo Error: M2_HOME is set to an invalid directory. >&2 -echo M2_HOME = "%M2_HOME%" >&2 -echo Please set the M2_HOME variable in your environment to match the >&2 -echo location of the Maven installation >&2 -echo. -goto error -@REM ==== END VALIDATION ==== - -: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 - -@REM -- Regular WinNT shell -set MAVEN_CMD_LINE_ARGS=%* -goto endInit - -@REM The 4NT Shell from jp software -:4NTArgs -set MAVEN_CMD_LINE_ARGS=%$ -goto endInit - -:Win9xArg -@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= -:Win9xApp -if %1a==a goto endInit -set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1 -shift -goto Win9xApp - -@REM Reaching here means variables are defined and arguments have been captured -:endInit - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -if NOT "%OS%"=="Windows_NT" goto Win9xAdditionalConfig - -setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% -goto endReadAdditionalConfig - -:Win9xAdditionalConfig -@REM -- Win9x can only read the first line of the file -set /P JVM_CONFIG_MAVEN_PROPS=<"%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" - -:endReadAdditionalConfig - -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\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" -goto runm2 - -@REM The 4NT Shell from jp software -:4NTCWJars -for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i" -goto runm2 - -@REM Start MAVEN2 -:runm2 -set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %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 -set MAVEN_JAVA_EXE= -set MAVEN_CMD_LINE_ARGS= -goto postExec - -:endNT -@endlocal & set ERROR_CODE=%ERROR_CODE% - -:postExec - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -:skipRcPost - -@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% - - diff --git a/apache-maven/src/bin/mvnDebug.bat b/apache-maven/src/bin/mvn.cmd similarity index 68% rename from apache-maven/src/bin/mvnDebug.bat rename to apache-maven/src/bin/mvn.cmd index 6452638fb2..4fad0939c1 100644 --- a/apache-maven/src/bin/mvnDebug.bat +++ b/apache-maven/src/bin/mvn.cmd @@ -38,23 +38,22 @@ @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% -@echo Preparing to Execute Maven in Debug Mode - @REM set %HOME% to equivalent of $HOME if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" :skipRcPre +@setlocal + set ERROR_CODE=0 -@REM set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" @setlocal -if "%OS%"=="WINNT" @setlocal - -set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal @REM ==== START VALIDATION ==== if not "%JAVA_HOME%" == "" goto OkJHome @@ -80,8 +79,7 @@ goto error :chkMHome if not "%M2_HOME%"=="" goto valMHome -if "%OS%"=="Windows_NT" SET "M2_HOME=%~dp0.." -if "%OS%"=="WINNT" SET "M2_HOME=%~dp0.." +SET "M2_HOME=%~dp0.." if not "%M2_HOME%"=="" goto valMHome echo. @@ -94,12 +92,12 @@ goto error :valMHome :stripMHome -if not "_%M2_HOME:~-1%"=="_\" goto checkMBat +if not "_%M2_HOME:~-1%"=="_\" goto checkMCmd set "M2_HOME=%M2_HOME:~0,-1%" goto stripMHome -:checkMBat -if exist "%M2_HOME%\bin\mvn.bat" goto init +:checkMCmd +if exist "%M2_HOME%\bin\mvn.cmd" goto init echo. echo Error: M2_HOME is set to an invalid directory. >&2 @@ -111,40 +109,8 @@ goto error @REM ==== END VALIDATION ==== :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 - -@REM -- Regular WinNT shell set MAVEN_CMD_LINE_ARGS=%* -goto endInit - -@REM The 4NT Shell from jp software -:4NTArgs -set MAVEN_CMD_LINE_ARGS=%$ -goto endInit - -:Win9xArg -@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= -:Win9xApp -if %1a==a goto endInit -set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1 -shift -goto Win9xApp - -@REM Reaching here means variables are defined and arguments have been captured -:endInit @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -174,70 +140,37 @@ cd "%EXEC_DIR%" IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig -if NOT "%OS%"=="Windows_NT" goto Win9xAdditionalConfig - -setlocal EnableExtensions EnableDelayedExpansion +@setlocal EnableExtensions EnableDelayedExpansion for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% -goto endReadAdditionalConfig +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% -:Win9xAdditionalConfig -@REM -- Win9x can only read the first line of the file -set /P JVM_CONFIG_MAVEN_PROPS=<"%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" - :endReadAdditionalConfig 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\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" -goto runm2 -@REM The 4NT Shell from jp software -:4NTCWJars -for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i" -goto runm2 - -@REM Start MAVEN2 -:runm2 set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %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 -set MAVEN_JAVA_EXE= -set MAVEN_CMD_LINE_ARGS= -goto postExec - -:endNT @endlocal & set ERROR_CODE=%ERROR_CODE% -:postExec - if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" :skipRcPost -@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' if "%MAVEN_BATCH_PAUSE%" == "on" pause if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% -cmd /C exit /B %ERROR_CODE% - - +exit /B %ERROR_CODE% diff --git a/apache-maven/src/bin/mvnDebug.cmd b/apache-maven/src/bin/mvnDebug.cmd new file mode 100644 index 0000000000..1f0d3bfb3b --- /dev/null +++ b/apache-maven/src/bin/mvnDebug.cmd @@ -0,0 +1,31 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script to run mvn.cmd with the following additional +@REM Java VM settings: +@REM +@REM -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM +@REM ---------------------------------------------------------------------------- + +@setlocal +@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 + +@call "%~dp0"mvn.cmd %*