/maven/bin/mvnDebug.bat

https://github.com/ajakubo1/opennms · Batch · 199 lines · 158 code · 41 blank · 0 comment · 38 complexity · a4fc652916bb0174e045266c4e94a7df 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. @REM ----------------------------------------------------------------------------
  20. @REM Maven2 Start Up Batch script
  21. @REM
  22. @REM Required ENV vars:
  23. @REM JAVA_HOME - location of a JDK home dir
  24. @REM
  25. @REM Optional ENV vars
  26. @REM M2_HOME - location of maven2's installed home dir
  27. @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
  28. @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
  29. @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
  30. @REM e.g. to debug Maven itself, use
  31. @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  32. @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
  33. @REM ----------------------------------------------------------------------------
  34. @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
  35. @echo off
  36. @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
  37. @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
  38. @echo Preparing to Execute Maven in Debug Mode
  39. @REM set %HOME% to equivalent of $HOME
  40. if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
  41. @REM Execute a user defined script before this one
  42. if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
  43. if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
  44. :skipRcPre
  45. set ERROR_CODE=0
  46. @REM set local scope for the variables with windows NT shell
  47. if "%OS%"=="Windows_NT" @setlocal
  48. if "%OS%"=="WINNT" @setlocal
  49. set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  50. @REM ==== START VALIDATION ====
  51. if not "%JAVA_HOME%" == "" goto OkJHome
  52. echo.
  53. echo Error: JAVA_HOME not found in your environment. >&2
  54. echo Please set the JAVA_HOME variable in your environment to match the >&2
  55. echo location of your Java installation >&2
  56. echo.
  57. goto error
  58. :OkJHome
  59. if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome
  60. echo.
  61. echo Error: JAVA_HOME is set to an invalid directory. >&2
  62. echo JAVA_HOME = "%JAVA_HOME%" >&2
  63. echo Please set the JAVA_HOME variable in your environment to match the >&2
  64. echo location of your Java installation >&2
  65. echo.
  66. goto error
  67. :chkMHome
  68. if not "%M2_HOME%"=="" goto valMHome
  69. if "%OS%"=="Windows_NT" SET "M2_HOME=%~dp0.."
  70. if "%OS%"=="WINNT" SET "M2_HOME=%~dp0.."
  71. if not "%M2_HOME%"=="" goto valMHome
  72. echo.
  73. echo Error: M2_HOME not found in your environment. >&2
  74. echo Please set the M2_HOME variable in your environment to match the >&2
  75. echo location of the Maven installation >&2
  76. echo.
  77. goto error
  78. :valMHome
  79. :stripMHome
  80. if not "_%M2_HOME:~-1%"=="_\" goto checkMBat
  81. set "M2_HOME=%M2_HOME:~0,-1%"
  82. goto stripMHome
  83. :checkMBat
  84. if exist "%M2_HOME%\bin\mvn.bat" goto init
  85. echo.
  86. echo Error: M2_HOME is set to an invalid directory. >&2
  87. echo M2_HOME = "%M2_HOME%" >&2
  88. echo Please set the M2_HOME variable in your environment to match the >&2
  89. echo location of the Maven installation >&2
  90. echo.
  91. goto error
  92. @REM ==== END VALIDATION ====
  93. :init
  94. @REM Decide how to startup depending on the version of windows
  95. @REM -- Windows NT with Novell Login
  96. if "%OS%"=="WINNT" goto WinNTNovell
  97. @REM -- Win98ME
  98. if NOT "%OS%"=="Windows_NT" goto Win9xArg
  99. :WinNTNovell
  100. @REM -- 4NT shell
  101. if "%@eval[2+2]" == "4" goto 4NTArgs
  102. @REM -- Regular WinNT shell
  103. set MAVEN_CMD_LINE_ARGS=%*
  104. goto endInit
  105. @REM The 4NT Shell from jp software
  106. :4NTArgs
  107. set MAVEN_CMD_LINE_ARGS=%$
  108. goto endInit
  109. :Win9xArg
  110. @REM Slurp the command line arguments. This loop allows for an unlimited number
  111. @REM of agruments (up to the command line limit, anyway).
  112. set MAVEN_CMD_LINE_ARGS=
  113. :Win9xApp
  114. if %1a==a goto endInit
  115. set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
  116. shift
  117. goto Win9xApp
  118. @REM Reaching here means variables are defined and arguments have been captured
  119. :endInit
  120. SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
  121. @REM -- 4NT shell
  122. if "%@eval[2+2]" == "4" goto 4NTCWJars
  123. @REM -- Regular WinNT shell
  124. for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
  125. goto runm2
  126. @REM The 4NT Shell from jp software
  127. :4NTCWJars
  128. for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i"
  129. goto runm2
  130. @REM Start MAVEN2
  131. :runm2
  132. set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
  133. %MAVEN_JAVA_EXE% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
  134. if ERRORLEVEL 1 goto error
  135. goto end
  136. :error
  137. if "%OS%"=="Windows_NT" @endlocal
  138. if "%OS%"=="WINNT" @endlocal
  139. set ERROR_CODE=1
  140. :end
  141. @REM set local scope for the variables with windows NT shell
  142. if "%OS%"=="Windows_NT" goto endNT
  143. if "%OS%"=="WINNT" goto endNT
  144. @REM For old DOS remove the set variables from ENV - we assume they were not set
  145. @REM before we started - at least we don't leave any baggage around
  146. set MAVEN_JAVA_EXE=
  147. set MAVEN_CMD_LINE_ARGS=
  148. goto postExec
  149. :endNT
  150. @endlocal & set ERROR_CODE=%ERROR_CODE%
  151. :postExec
  152. if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
  153. if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
  154. :skipRcPost
  155. @REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on'
  156. if "%MAVEN_BATCH_PAUSE%" == "on" pause
  157. if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
  158. exit /B %ERROR_CODE%