mvnw.cmd 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. @REM ----------------------------------------------------------------------------
  2. @REM Copyright 1999-2019 Seata.io Group.
  3. @REM
  4. @REM Licensed under the Apache License, Version 2.0 (the "License");
  5. @REM you may not use this file except in compliance with the License.
  6. @REM You may obtain a copy of the License at
  7. @REM
  8. @REM http://www.apache.org/licenses/LICENSE-2.0
  9. @REM
  10. @REM Unless required by applicable law or agreed to in writing, software
  11. @REM distributed under the License is distributed on an "AS IS" BASIS,
  12. @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. @REM See the License for the specific language governing permissions and
  14. @REM limitations under the License.
  15. @REM ----------------------------------------------------------------------------
  16. @REM ----------------------------------------------------------------------------
  17. @REM Maven2 Start Up Batch script
  18. @REM
  19. @REM Required ENV vars:
  20. @REM JAVA_HOME - location of a JDK home dir
  21. @REM
  22. @REM Optional ENV vars
  23. @REM M2_HOME - location of maven2's installed home dir
  24. @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
  25. @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
  26. @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
  27. @REM e.g. to debug Maven itself, use
  28. @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  29. @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
  30. @REM ----------------------------------------------------------------------------
  31. @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
  32. @echo off
  33. @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
  34. @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
  35. @REM set %HOME% to equivalent of $HOME
  36. if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
  37. @REM Execute a user defined script before this one
  38. if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
  39. @REM check for pre script, once with legacy .bat ending and once with .cmd ending
  40. if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
  41. if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
  42. :skipRcPre
  43. @setlocal
  44. set ERROR_CODE=0
  45. @REM To isolate internal variables from possible post scripts, we use another setlocal
  46. @setlocal
  47. @REM ==== START VALIDATION ====
  48. if not "%JAVA_HOME%" == "" goto OkJHome
  49. echo.
  50. echo Error: JAVA_HOME not found in your environment. >&2
  51. echo Please set the JAVA_HOME variable in your environment to match the >&2
  52. echo location of your Java installation. >&2
  53. echo.
  54. goto error
  55. :OkJHome
  56. if exist "%JAVA_HOME%\bin\java.exe" goto init
  57. echo.
  58. echo Error: JAVA_HOME is set to an invalid directory. >&2
  59. echo JAVA_HOME = "%JAVA_HOME%" >&2
  60. echo Please set the JAVA_HOME variable in your environment to match the >&2
  61. echo location of your Java installation. >&2
  62. echo.
  63. goto error
  64. @REM ==== END VALIDATION ====
  65. :init
  66. @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
  67. @REM Fallback to current working directory if not found.
  68. set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
  69. IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
  70. set EXEC_DIR=%CD%
  71. set WDIR=%EXEC_DIR%
  72. :findBaseDir
  73. IF EXIST "%WDIR%"\.mvn goto baseDirFound
  74. cd ..
  75. IF "%WDIR%"=="%CD%" goto baseDirNotFound
  76. set WDIR=%CD%
  77. goto findBaseDir
  78. :baseDirFound
  79. set MAVEN_PROJECTBASEDIR=%WDIR%
  80. cd "%EXEC_DIR%"
  81. goto endDetectBaseDir
  82. :baseDirNotFound
  83. set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
  84. cd "%EXEC_DIR%"
  85. :endDetectBaseDir
  86. IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
  87. @setlocal EnableExtensions EnableDelayedExpansion
  88. for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
  89. @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
  90. :endReadAdditionalConfig
  91. SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
  92. set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
  93. set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
  94. %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
  95. if ERRORLEVEL 1 goto error
  96. goto end
  97. :error
  98. set ERROR_CODE=1
  99. :end
  100. @endlocal & set ERROR_CODE=%ERROR_CODE%
  101. if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
  102. @REM check for post script, once with legacy .bat ending and once with .cmd ending
  103. if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
  104. if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
  105. :skipRcPost
  106. @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
  107. if "%MAVEN_BATCH_PAUSE%" == "on" pause
  108. if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
  109. exit /B %ERROR_CODE%