PageRenderTime 43ms CodeModel.GetById 30ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/maven/bin/mvn.bat

https://github.com/ajakubo1/opennms
Batch | 196 lines | 156 code | 40 blank | 0 comment | 38 complexity | 055429c9bd34a755a729e9e2e43fdada MD5 | raw file
  1@REM ----------------------------------------------------------------------------
  2@REM Licensed to the Apache Software Foundation (ASF) under one
  3@REM or more contributor license agreements.  See the NOTICE file
  4@REM distributed with this work for additional information
  5@REM regarding copyright ownership.  The ASF licenses this file
  6@REM to you under the Apache License, Version 2.0 (the
  7@REM "License"); you may not use this file except in compliance
  8@REM with the License.  You may obtain a copy of the License at
  9@REM
 10@REM    http://www.apache.org/licenses/LICENSE-2.0
 11@REM
 12@REM Unless required by applicable law or agreed to in writing,
 13@REM software distributed under the License is distributed on an
 14@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15@REM KIND, either express or implied.  See the License for the
 16@REM specific language governing permissions and limitations
 17@REM under the License.
 18@REM ----------------------------------------------------------------------------
 19
 20@REM ----------------------------------------------------------------------------
 21@REM Maven2 Start Up Batch script
 22@REM
 23@REM Required ENV vars:
 24@REM JAVA_HOME - location of a JDK home dir
 25@REM
 26@REM Optional ENV vars
 27@REM M2_HOME - location of maven2's installed home dir
 28@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
 29@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
 30@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
 31@REM     e.g. to debug Maven itself, use
 32@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
 33@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
 34@REM ----------------------------------------------------------------------------
 35
 36@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
 37@echo off
 38@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
 39@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
 40
 41@REM set %HOME% to equivalent of $HOME
 42if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
 43
 44@REM Execute a user defined script before this one
 45if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
 46if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
 47:skipRcPre
 48
 49set ERROR_CODE=0
 50
 51@REM set local scope for the variables with windows NT shell
 52if "%OS%"=="Windows_NT" @setlocal
 53if "%OS%"=="WINNT" @setlocal
 54
 55@REM ==== START VALIDATION ====
 56if not "%JAVA_HOME%" == "" goto OkJHome
 57
 58echo.
 59echo Error: JAVA_HOME not found in your environment. >&2
 60echo Please set the JAVA_HOME variable in your environment to match the >&2
 61echo location of your Java installation. >&2
 62echo.
 63goto error
 64
 65:OkJHome
 66if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome
 67
 68echo.
 69echo Error: JAVA_HOME is set to an invalid directory. >&2
 70echo JAVA_HOME = "%JAVA_HOME%" >&2
 71echo Please set the JAVA_HOME variable in your environment to match the >&2
 72echo location of your Java installation. >&2
 73echo.
 74goto error
 75
 76:chkMHome
 77if not "%M2_HOME%"=="" goto valMHome
 78
 79if "%OS%"=="Windows_NT" SET "M2_HOME=%~dp0.."
 80if "%OS%"=="WINNT" SET "M2_HOME=%~dp0.."
 81if not "%M2_HOME%"=="" goto valMHome
 82
 83echo.
 84echo Error: M2_HOME not found in your environment. >&2
 85echo Please set the M2_HOME variable in your environment to match the >&2
 86echo location of the Maven installation. >&2
 87echo.
 88goto error
 89
 90:valMHome
 91
 92:stripMHome
 93if not "_%M2_HOME:~-1%"=="_\" goto checkMBat
 94set "M2_HOME=%M2_HOME:~0,-1%"
 95goto stripMHome
 96
 97:checkMBat
 98if exist "%M2_HOME%\bin\mvn.bat" goto init
 99
100echo.
101echo Error: M2_HOME is set to an invalid directory. >&2
102echo M2_HOME = "%M2_HOME%" >&2
103echo Please set the M2_HOME variable in your environment to match the >&2
104echo location of the Maven installation >&2
105echo.
106goto error
107@REM ==== END VALIDATION ====
108
109:init
110@REM Decide how to startup depending on the version of windows
111
112@REM -- Windows NT with Novell Login
113if "%OS%"=="WINNT" goto WinNTNovell
114
115@REM -- Win98ME
116if NOT "%OS%"=="Windows_NT" goto Win9xArg
117
118:WinNTNovell
119
120@REM -- 4NT shell
121if "%@eval[2+2]" == "4" goto 4NTArgs
122
123@REM -- Regular WinNT shell
124set MAVEN_CMD_LINE_ARGS=%*
125goto endInit
126
127@REM The 4NT Shell from jp software
128:4NTArgs
129set MAVEN_CMD_LINE_ARGS=%$
130goto endInit
131
132:Win9xArg
133@REM Slurp the command line arguments.  This loop allows for an unlimited number
134@REM of agruments (up to the command line limit, anyway).
135set MAVEN_CMD_LINE_ARGS=
136:Win9xApp
137if %1a==a goto endInit
138set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
139shift
140goto Win9xApp
141
142@REM Reaching here means variables are defined and arguments have been captured
143:endInit
144SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
145
146@REM -- 4NT shell
147if "%@eval[2+2]" == "4" goto 4NTCWJars
148
149@REM -- Regular WinNT shell
150for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
151goto runm2
152
153@REM The 4NT Shell from jp software
154:4NTCWJars
155for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i"
156goto runm2
157
158@REM Start MAVEN2
159:runm2
160set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
161%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
162if ERRORLEVEL 1 goto error
163goto end
164
165:error
166if "%OS%"=="Windows_NT" @endlocal
167if "%OS%"=="WINNT" @endlocal
168set ERROR_CODE=1
169
170:end
171@REM set local scope for the variables with windows NT shell
172if "%OS%"=="Windows_NT" goto endNT
173if "%OS%"=="WINNT" goto endNT
174
175@REM For old DOS remove the set variables from ENV - we assume they were not set
176@REM before we started - at least we don't leave any baggage around
177set MAVEN_JAVA_EXE=
178set MAVEN_CMD_LINE_ARGS=
179goto postExec
180
181:endNT
182@endlocal & set ERROR_CODE=%ERROR_CODE%
183
184:postExec
185
186if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
187if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
188:skipRcPost
189
190@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on'
191if "%MAVEN_BATCH_PAUSE%" == "on" pause
192
193if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
194
195cmd /C exit /B %ERROR_CODE%
196