xref: /aosp_15_r20/external/aws-sdk-java-v2/mvnw.cmd (revision 8a52c7834d808308836a99fc2a6e0ed8db339086)
1*8a52c783SCole Faust@REM ----------------------------------------------------------------------------
2*8a52c783SCole Faust@REM Licensed to the Apache Software Foundation (ASF) under one
3*8a52c783SCole Faust@REM or more contributor license agreements.  See the NOTICE file
4*8a52c783SCole Faust@REM distributed with this work for additional information
5*8a52c783SCole Faust@REM regarding copyright ownership.  The ASF licenses this file
6*8a52c783SCole Faust@REM to you under the Apache License, Version 2.0 (the
7*8a52c783SCole Faust@REM "License"); you may not use this file except in compliance
8*8a52c783SCole Faust@REM with the License.  You may obtain a copy of the License at
9*8a52c783SCole Faust@REM
10*8a52c783SCole Faust@REM    http://www.apache.org/licenses/LICENSE-2.0
11*8a52c783SCole Faust@REM
12*8a52c783SCole Faust@REM Unless required by applicable law or agreed to in writing,
13*8a52c783SCole Faust@REM software distributed under the License is distributed on an
14*8a52c783SCole Faust@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15*8a52c783SCole Faust@REM KIND, either express or implied.  See the License for the
16*8a52c783SCole Faust@REM specific language governing permissions and limitations
17*8a52c783SCole Faust@REM under the License.
18*8a52c783SCole Faust@REM ----------------------------------------------------------------------------
19*8a52c783SCole Faust
20*8a52c783SCole Faust@REM ----------------------------------------------------------------------------
21*8a52c783SCole Faust@REM Apache Maven Wrapper startup batch script, version 3.2.0
22*8a52c783SCole Faust@REM
23*8a52c783SCole Faust@REM Required ENV vars:
24*8a52c783SCole Faust@REM JAVA_HOME - location of a JDK home dir
25*8a52c783SCole Faust@REM
26*8a52c783SCole Faust@REM Optional ENV vars
27*8a52c783SCole Faust@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
28*8a52c783SCole Faust@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
29*8a52c783SCole Faust@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
30*8a52c783SCole Faust@REM     e.g. to debug Maven itself, use
31*8a52c783SCole Faust@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
32*8a52c783SCole Faust@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
33*8a52c783SCole Faust@REM ----------------------------------------------------------------------------
34*8a52c783SCole Faust
35*8a52c783SCole Faust@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
36*8a52c783SCole Faust@echo off
37*8a52c783SCole Faust@REM set title of command window
38*8a52c783SCole Fausttitle %0
39*8a52c783SCole Faust@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
40*8a52c783SCole Faust@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
41*8a52c783SCole Faust
42*8a52c783SCole Faust@REM set %HOME% to equivalent of $HOME
43*8a52c783SCole Faustif "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
44*8a52c783SCole Faust
45*8a52c783SCole Faust@REM Execute a user defined script before this one
46*8a52c783SCole Faustif not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
47*8a52c783SCole Faust@REM check for pre script, once with legacy .bat ending and once with .cmd ending
48*8a52c783SCole Faustif exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
49*8a52c783SCole Faustif exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
50*8a52c783SCole Faust:skipRcPre
51*8a52c783SCole Faust
52*8a52c783SCole Faust@setlocal
53*8a52c783SCole Faust
54*8a52c783SCole Faustset ERROR_CODE=0
55*8a52c783SCole Faust
56*8a52c783SCole Faust@REM To isolate internal variables from possible post scripts, we use another setlocal
57*8a52c783SCole Faust@setlocal
58*8a52c783SCole Faust
59*8a52c783SCole Faust@REM ==== START VALIDATION ====
60*8a52c783SCole Faustif not "%JAVA_HOME%" == "" goto OkJHome
61*8a52c783SCole Faust
62*8a52c783SCole Faustecho.
63*8a52c783SCole Faustecho Error: JAVA_HOME not found in your environment. >&2
64*8a52c783SCole Faustecho Please set the JAVA_HOME variable in your environment to match the >&2
65*8a52c783SCole Faustecho location of your Java installation. >&2
66*8a52c783SCole Faustecho.
67*8a52c783SCole Faustgoto error
68*8a52c783SCole Faust
69*8a52c783SCole Faust:OkJHome
70*8a52c783SCole Faustif exist "%JAVA_HOME%\bin\java.exe" goto init
71*8a52c783SCole Faust
72*8a52c783SCole Faustecho.
73*8a52c783SCole Faustecho Error: JAVA_HOME is set to an invalid directory. >&2
74*8a52c783SCole Faustecho JAVA_HOME = "%JAVA_HOME%" >&2
75*8a52c783SCole Faustecho Please set the JAVA_HOME variable in your environment to match the >&2
76*8a52c783SCole Faustecho location of your Java installation. >&2
77*8a52c783SCole Faustecho.
78*8a52c783SCole Faustgoto error
79*8a52c783SCole Faust
80*8a52c783SCole Faust@REM ==== END VALIDATION ====
81*8a52c783SCole Faust
82*8a52c783SCole Faust:init
83*8a52c783SCole Faust
84*8a52c783SCole Faust@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
85*8a52c783SCole Faust@REM Fallback to current working directory if not found.
86*8a52c783SCole Faust
87*8a52c783SCole Faustset MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
88*8a52c783SCole FaustIF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
89*8a52c783SCole Faust
90*8a52c783SCole Faustset EXEC_DIR=%CD%
91*8a52c783SCole Faustset WDIR=%EXEC_DIR%
92*8a52c783SCole Faust:findBaseDir
93*8a52c783SCole FaustIF EXIST "%WDIR%"\.mvn goto baseDirFound
94*8a52c783SCole Faustcd ..
95*8a52c783SCole FaustIF "%WDIR%"=="%CD%" goto baseDirNotFound
96*8a52c783SCole Faustset WDIR=%CD%
97*8a52c783SCole Faustgoto findBaseDir
98*8a52c783SCole Faust
99*8a52c783SCole Faust:baseDirFound
100*8a52c783SCole Faustset MAVEN_PROJECTBASEDIR=%WDIR%
101*8a52c783SCole Faustcd "%EXEC_DIR%"
102*8a52c783SCole Faustgoto endDetectBaseDir
103*8a52c783SCole Faust
104*8a52c783SCole Faust:baseDirNotFound
105*8a52c783SCole Faustset MAVEN_PROJECTBASEDIR=%EXEC_DIR%
106*8a52c783SCole Faustcd "%EXEC_DIR%"
107*8a52c783SCole Faust
108*8a52c783SCole Faust:endDetectBaseDir
109*8a52c783SCole Faust
110*8a52c783SCole FaustIF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
111*8a52c783SCole Faust
112*8a52c783SCole Faust@setlocal EnableExtensions EnableDelayedExpansion
113*8a52c783SCole Faustfor /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
114*8a52c783SCole Faust@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
115*8a52c783SCole Faust
116*8a52c783SCole Faust:endReadAdditionalConfig
117*8a52c783SCole Faust
118*8a52c783SCole FaustSET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
119*8a52c783SCole Faustset WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120*8a52c783SCole Faustset WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121*8a52c783SCole Faust
122*8a52c783SCole Faustset WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
123*8a52c783SCole Faust
124*8a52c783SCole FaustFOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
125*8a52c783SCole Faust    IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
126*8a52c783SCole Faust)
127*8a52c783SCole Faust
128*8a52c783SCole Faust@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
129*8a52c783SCole Faust@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
130*8a52c783SCole Faustif exist %WRAPPER_JAR% (
131*8a52c783SCole Faust    if "%MVNW_VERBOSE%" == "true" (
132*8a52c783SCole Faust        echo Found %WRAPPER_JAR%
133*8a52c783SCole Faust    )
134*8a52c783SCole Faust) else (
135*8a52c783SCole Faust    if not "%MVNW_REPOURL%" == "" (
136*8a52c783SCole Faust        SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
137*8a52c783SCole Faust    )
138*8a52c783SCole Faust    if "%MVNW_VERBOSE%" == "true" (
139*8a52c783SCole Faust        echo Couldn't find %WRAPPER_JAR%, downloading it ...
140*8a52c783SCole Faust        echo Downloading from: %WRAPPER_URL%
141*8a52c783SCole Faust    )
142*8a52c783SCole Faust
143*8a52c783SCole Faust    powershell -Command "&{"^
144*8a52c783SCole Faust		"$webclient = new-object System.Net.WebClient;"^
145*8a52c783SCole Faust		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
146*8a52c783SCole Faust		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
147*8a52c783SCole Faust		"}"^
148*8a52c783SCole Faust		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
149*8a52c783SCole Faust		"}"
150*8a52c783SCole Faust    if "%MVNW_VERBOSE%" == "true" (
151*8a52c783SCole Faust        echo Finished downloading %WRAPPER_JAR%
152*8a52c783SCole Faust    )
153*8a52c783SCole Faust)
154*8a52c783SCole Faust@REM End of extension
155*8a52c783SCole Faust
156*8a52c783SCole Faust@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
157*8a52c783SCole FaustSET WRAPPER_SHA_256_SUM=""
158*8a52c783SCole FaustFOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
159*8a52c783SCole Faust    IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
160*8a52c783SCole Faust)
161*8a52c783SCole FaustIF NOT %WRAPPER_SHA_256_SUM%=="" (
162*8a52c783SCole Faust    powershell -Command "&{"^
163*8a52c783SCole Faust       "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
164*8a52c783SCole Faust       "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
165*8a52c783SCole Faust       "  Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
166*8a52c783SCole Faust       "  Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
167*8a52c783SCole Faust       "  Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
168*8a52c783SCole Faust       "  exit 1;"^
169*8a52c783SCole Faust       "}"^
170*8a52c783SCole Faust       "}"
171*8a52c783SCole Faust    if ERRORLEVEL 1 goto error
172*8a52c783SCole Faust)
173*8a52c783SCole Faust
174*8a52c783SCole Faust@REM Provide a "standardized" way to retrieve the CLI args that will
175*8a52c783SCole Faust@REM work with both Windows and non-Windows executions.
176*8a52c783SCole Faustset MAVEN_CMD_LINE_ARGS=%*
177*8a52c783SCole Faust
178*8a52c783SCole Faust%MAVEN_JAVA_EXE% ^
179*8a52c783SCole Faust  %JVM_CONFIG_MAVEN_PROPS% ^
180*8a52c783SCole Faust  %MAVEN_OPTS% ^
181*8a52c783SCole Faust  %MAVEN_DEBUG_OPTS% ^
182*8a52c783SCole Faust  -classpath %WRAPPER_JAR% ^
183*8a52c783SCole Faust  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
184*8a52c783SCole Faust  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
185*8a52c783SCole Faustif ERRORLEVEL 1 goto error
186*8a52c783SCole Faustgoto end
187*8a52c783SCole Faust
188*8a52c783SCole Faust:error
189*8a52c783SCole Faustset ERROR_CODE=1
190*8a52c783SCole Faust
191*8a52c783SCole Faust:end
192*8a52c783SCole Faust@endlocal & set ERROR_CODE=%ERROR_CODE%
193*8a52c783SCole Faust
194*8a52c783SCole Faustif not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
195*8a52c783SCole Faust@REM check for post script, once with legacy .bat ending and once with .cmd ending
196*8a52c783SCole Faustif exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
197*8a52c783SCole Faustif exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
198*8a52c783SCole Faust:skipRcPost
199*8a52c783SCole Faust
200*8a52c783SCole Faust@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
201*8a52c783SCole Faustif "%MAVEN_BATCH_PAUSE%"=="on" pause
202*8a52c783SCole Faust
203*8a52c783SCole Faustif "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
204*8a52c783SCole Faust
205*8a52c783SCole Faustcmd /C exit /B %ERROR_CODE%
206