1
1
#! /bin/sh
2
- # ----------------------------------------------------------------------------
3
- # Licensed to the Apache Software Foundation (ASF) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The ASF licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
2
+ #
3
+ # Copyright (c) 2010-2024. Axon Framework
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
10
8
#
11
9
# http://www.apache.org/licenses/LICENSE-2.0
12
10
#
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
- # ----------------------------------------------------------------------------
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
20
17
21
18
# ----------------------------------------------------------------------------
22
- # Maven2 Start Up Batch script
19
+ # Apache Maven Wrapper startup batch script, version 3.2.0
23
20
#
24
21
# Required ENV vars:
25
22
# ------------------
26
23
# JAVA_HOME - location of a JDK home dir
27
24
#
28
25
# Optional ENV vars
29
26
# -----------------
30
- # M2_HOME - location of maven2's installed home dir
31
27
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
32
28
# e.g. to debug Maven itself, use
33
29
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
36
32
37
33
if [ -z " $MAVEN_SKIP_RC " ] ; then
38
34
35
+ if [ -f /usr/local/etc/mavenrc ] ; then
36
+ . /usr/local/etc/mavenrc
37
+ fi
38
+
39
39
if [ -f /etc/mavenrc ] ; then
40
40
. /etc/mavenrc
41
41
fi
50
50
cygwin=false;
51
51
darwin=false;
52
52
mingw=false
53
- case " ` uname` " in
53
+ case " $( uname) " in
54
54
CYGWIN* ) cygwin=true ;;
55
55
MINGW* ) mingw=true;;
56
56
Darwin* ) darwin=true
57
57
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58
58
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59
59
if [ -z " $JAVA_HOME " ]; then
60
60
if [ -x " /usr/libexec/java_home" ]; then
61
- export JAVA_HOME=" ` /usr/libexec/java_home` "
61
+ JAVA_HOME=" $( /usr/libexec/java_home) " ; export JAVA_HOME
62
62
else
63
- export JAVA_HOME=" /Library/Java/Home"
63
+ JAVA_HOME=" /Library/Java/Home" ; export JAVA_HOME
64
64
fi
65
65
fi
66
66
;;
67
67
esac
68
68
69
69
if [ -z " $JAVA_HOME " ] ; then
70
70
if [ -r /etc/gentoo-release ] ; then
71
- JAVA_HOME=` java-config --jre-home`
71
+ JAVA_HOME=$( java-config --jre-home)
72
72
fi
73
73
fi
74
74
75
- if [ -z " $M2_HOME " ] ; then
76
- # # resolve links - $0 may be a link to maven's home
77
- PRG=" $0 "
78
-
79
- # need this for relative symlinks
80
- while [ -h " $PRG " ] ; do
81
- ls=` ls -ld " $PRG " `
82
- link=` expr " $ls " : ' .*-> \(.*\)$' `
83
- if expr " $link " : ' /.*' > /dev/null; then
84
- PRG=" $link "
85
- else
86
- PRG=" ` dirname " $PRG " ` /$link "
87
- fi
88
- done
89
-
90
- saveddir=` pwd`
91
-
92
- M2_HOME=` dirname " $PRG " ` /..
93
-
94
- # make it fully qualified
95
- M2_HOME=` cd " $M2_HOME " && pwd`
96
-
97
- cd " $saveddir "
98
- # echo Using m2 at $M2_HOME
99
- fi
100
-
101
75
# For Cygwin, ensure paths are in UNIX format before anything is touched
102
76
if $cygwin ; then
103
- [ -n " $M2_HOME " ] &&
104
- M2_HOME=` cygpath --unix " $M2_HOME " `
105
77
[ -n " $JAVA_HOME " ] &&
106
- JAVA_HOME=` cygpath --unix " $JAVA_HOME " `
78
+ JAVA_HOME=$( cygpath --unix " $JAVA_HOME " )
107
79
[ -n " $CLASSPATH " ] &&
108
- CLASSPATH=` cygpath --path --unix " $CLASSPATH " `
80
+ CLASSPATH=$( cygpath --path --unix " $CLASSPATH " )
109
81
fi
110
82
111
83
# For Mingw, ensure paths are in UNIX format before anything is touched
112
84
if $mingw ; then
113
- [ -n " $M2_HOME " ] &&
114
- M2_HOME=" ` (cd " $M2_HOME " ; pwd)` "
115
- [ -n " $JAVA_HOME " ] &&
116
- JAVA_HOME=" ` (cd " $JAVA_HOME " ; pwd)` "
117
- # TODO classpath?
85
+ [ -n " $JAVA_HOME " ] && [ -d " $JAVA_HOME " ] &&
86
+ JAVA_HOME=" $( cd " $JAVA_HOME " || (echo " cannot cd into $JAVA_HOME ." ; exit 1); pwd) "
118
87
fi
119
88
120
89
if [ -z " $JAVA_HOME " ]; then
121
- javaExecutable=" ` which javac` "
122
- if [ -n " $javaExecutable " ] && ! [ " ` expr \" $javaExecutable \" : ' \([^ ]*\)' ` " = " no" ]; then
90
+ javaExecutable=" $( which javac) "
91
+ if [ -n " $javaExecutable " ] && ! [ " $( expr " \" $javaExecutable \" " : ' \([^ ]*\)' ) " = " no" ]; then
123
92
# readlink(1) is not available as standard on Solaris 10.
124
- readLink=` which readlink`
125
- if [ ! ` expr " $readLink " : ' \([^ ]*\)' ` = " no" ]; then
93
+ readLink=$( which readlink)
94
+ if [ ! " $( expr " $readLink " : ' \([^ ]*\)' ) " = " no" ]; then
126
95
if $darwin ; then
127
- javaHome=" ` dirname \" $javaExecutable \" ` "
128
- javaExecutable=" ` cd \" $javaHome \" && pwd -P` /javac"
96
+ javaHome=" $( dirname " \" $javaExecutable \" " ) "
97
+ javaExecutable=" $( cd " \" $javaHome \" " && pwd -P) /javac"
129
98
else
130
- javaExecutable=" ` readlink -f \" $javaExecutable \" ` "
99
+ javaExecutable=" $( readlink -f " \" $javaExecutable \" " ) "
131
100
fi
132
- javaHome=" ` dirname \" $javaExecutable \" ` "
133
- javaHome=` expr " $javaHome " : ' \(.*\)/bin' `
101
+ javaHome=" $( dirname " \" $javaExecutable \" " ) "
102
+ javaHome=$( expr " $javaHome " : ' \(.*\)/bin' )
134
103
JAVA_HOME=" $javaHome "
135
104
export JAVA_HOME
136
105
fi
@@ -146,7 +115,7 @@ if [ -z "$JAVACMD" ] ; then
146
115
JAVACMD=" $JAVA_HOME /bin/java"
147
116
fi
148
117
else
149
- JAVACMD=" ` which java` "
118
+ JAVACMD=" $( \u nset -f command 2> /dev/null ; \c ommand -v java) "
150
119
fi
151
120
fi
152
121
@@ -160,12 +129,9 @@ if [ -z "$JAVA_HOME" ] ; then
160
129
echo " Warning: JAVA_HOME environment variable is not set."
161
130
fi
162
131
163
- CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164
-
165
132
# traverses directory structure from process work directory to filesystem root
166
133
# first directory with .mvn subdirectory is considered project base directory
167
134
find_maven_basedir () {
168
-
169
135
if [ -z " $1 " ]
170
136
then
171
137
echo " Path not specified to find_maven_basedir"
@@ -181,47 +147,159 @@ find_maven_basedir() {
181
147
fi
182
148
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
183
149
if [ -d " ${wdir} " ]; then
184
- wdir=` cd " $wdir /.." ; pwd`
150
+ wdir=$( cd " $wdir /.." || exit 1 ; pwd)
185
151
fi
186
152
# end of workaround
187
153
done
188
- echo " ${ basedir} "
154
+ printf ' %s ' " $( cd " $ basedir" || exit 1 ; pwd ) "
189
155
}
190
156
191
157
# concatenates all lines of a file
192
158
concat_lines () {
193
159
if [ -f " $1 " ]; then
194
- echo " $( tr -s ' \n' ' ' < " $1 " ) "
160
+ # Remove \r in case we run on Windows within Git Bash
161
+ # and check out the repository with auto CRLF management
162
+ # enabled. Otherwise, we may read lines that are delimited with
163
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
164
+ # splitting rules.
165
+ tr -s ' \r\n' ' ' < " $1 "
195
166
fi
196
167
}
197
168
198
- BASE_DIR=` find_maven_basedir " $( pwd) " `
169
+ log () {
170
+ if [ " $MVNW_VERBOSE " = true ]; then
171
+ printf ' %s\n' " $1 "
172
+ fi
173
+ }
174
+
175
+ BASE_DIR=$( find_maven_basedir " $( dirname " $0 " ) " )
199
176
if [ -z " $BASE_DIR " ]; then
200
177
exit 1;
201
178
fi
202
179
203
- export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:- " $BASE_DIR " }
204
- if [ " $MVNW_VERBOSE " = true ]; then
205
- echo $MAVEN_PROJECTBASEDIR
180
+ MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:- " $BASE_DIR " } ; export MAVEN_PROJECTBASEDIR
181
+ log " $MAVEN_PROJECTBASEDIR "
182
+
183
+ # #########################################################################################
184
+ # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
185
+ # This allows using the maven wrapper in projects that prohibit checking in binary data.
186
+ # #########################################################################################
187
+ wrapperJarPath=" $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.jar"
188
+ if [ -r " $wrapperJarPath " ]; then
189
+ log " Found $wrapperJarPath "
190
+ else
191
+ log " Couldn't find $wrapperJarPath , downloading it ..."
192
+
193
+ if [ -n " $MVNW_REPOURL " ]; then
194
+ wrapperUrl=" $MVNW_REPOURL /org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
195
+ else
196
+ wrapperUrl=" https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
197
+ fi
198
+ while IFS=" =" read -r key value; do
199
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
200
+ safeValue=$( echo " $value " | tr -d ' \r' )
201
+ case " $key " in (wrapperUrl) wrapperUrl=" $safeValue " ; break ;;
202
+ esac
203
+ done < " $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.properties"
204
+ log " Downloading from: $wrapperUrl "
205
+
206
+ if $cygwin ; then
207
+ wrapperJarPath=$( cygpath --path --windows " $wrapperJarPath " )
208
+ fi
209
+
210
+ if command -v wget > /dev/null; then
211
+ log " Found wget ... using wget"
212
+ [ " $MVNW_VERBOSE " = true ] && QUIET=" " || QUIET=" --quiet"
213
+ if [ -z " $MVNW_USERNAME " ] || [ -z " $MVNW_PASSWORD " ]; then
214
+ wget $QUIET " $wrapperUrl " -O " $wrapperJarPath " || rm -f " $wrapperJarPath "
215
+ else
216
+ wget $QUIET --http-user=" $MVNW_USERNAME " --http-password=" $MVNW_PASSWORD " " $wrapperUrl " -O " $wrapperJarPath " || rm -f " $wrapperJarPath "
217
+ fi
218
+ elif command -v curl > /dev/null; then
219
+ log " Found curl ... using curl"
220
+ [ " $MVNW_VERBOSE " = true ] && QUIET=" " || QUIET=" --silent"
221
+ if [ -z " $MVNW_USERNAME " ] || [ -z " $MVNW_PASSWORD " ]; then
222
+ curl $QUIET -o " $wrapperJarPath " " $wrapperUrl " -f -L || rm -f " $wrapperJarPath "
223
+ else
224
+ curl $QUIET --user " $MVNW_USERNAME :$MVNW_PASSWORD " -o " $wrapperJarPath " " $wrapperUrl " -f -L || rm -f " $wrapperJarPath "
225
+ fi
226
+ else
227
+ log " Falling back to using Java to download"
228
+ javaSource=" $MAVEN_PROJECTBASEDIR /.mvn/wrapper/MavenWrapperDownloader.java"
229
+ javaClass=" $MAVEN_PROJECTBASEDIR /.mvn/wrapper/MavenWrapperDownloader.class"
230
+ # For Cygwin, switch paths to Windows format before running javac
231
+ if $cygwin ; then
232
+ javaSource=$( cygpath --path --windows " $javaSource " )
233
+ javaClass=$( cygpath --path --windows " $javaClass " )
234
+ fi
235
+ if [ -e " $javaSource " ]; then
236
+ if [ ! -e " $javaClass " ]; then
237
+ log " - Compiling MavenWrapperDownloader.java ..."
238
+ (" $JAVA_HOME /bin/javac" " $javaSource " )
239
+ fi
240
+ if [ -e " $javaClass " ]; then
241
+ log " - Running MavenWrapperDownloader.java ..."
242
+ (" $JAVA_HOME /bin/java" -cp .mvn/wrapper MavenWrapperDownloader " $wrapperUrl " " $wrapperJarPath " ) || rm -f " $wrapperJarPath "
243
+ fi
244
+ fi
245
+ fi
246
+ fi
247
+ # #########################################################################################
248
+ # End of extension
249
+ # #########################################################################################
250
+
251
+ # If specified, validate the SHA-256 sum of the Maven wrapper jar file
252
+ wrapperSha256Sum=" "
253
+ while IFS=" =" read -r key value; do
254
+ case " $key " in (wrapperSha256Sum) wrapperSha256Sum=$value ; break ;;
255
+ esac
256
+ done < " $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.properties"
257
+ if [ -n " $wrapperSha256Sum " ]; then
258
+ wrapperSha256Result=false
259
+ if command -v sha256sum > /dev/null; then
260
+ if echo " $wrapperSha256Sum $wrapperJarPath " | sha256sum -c > /dev/null 2>&1 ; then
261
+ wrapperSha256Result=true
262
+ fi
263
+ elif command -v shasum > /dev/null; then
264
+ if echo " $wrapperSha256Sum $wrapperJarPath " | shasum -a 256 -c > /dev/null 2>&1 ; then
265
+ wrapperSha256Result=true
266
+ fi
267
+ else
268
+ echo " Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
269
+ echo " Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
270
+ exit 1
271
+ fi
272
+ if [ $wrapperSha256Result = false ]; then
273
+ echo " Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
274
+ echo " Investigate or delete $wrapperJarPath to attempt a clean download." >&2
275
+ echo " If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
276
+ exit 1
277
+ fi
206
278
fi
279
+
207
280
MAVEN_OPTS=" $( concat_lines " $MAVEN_PROJECTBASEDIR /.mvn/jvm.config" ) $MAVEN_OPTS "
208
281
209
282
# For Cygwin, switch paths to Windows format before running java
210
283
if $cygwin ; then
211
- [ -n " $M2_HOME " ] &&
212
- M2_HOME=` cygpath --path --windows " $M2_HOME " `
213
284
[ -n " $JAVA_HOME " ] &&
214
- JAVA_HOME=` cygpath --path --windows " $JAVA_HOME " `
285
+ JAVA_HOME=$( cygpath --path --windows " $JAVA_HOME " )
215
286
[ -n " $CLASSPATH " ] &&
216
- CLASSPATH=` cygpath --path --windows " $CLASSPATH " `
287
+ CLASSPATH=$( cygpath --path --windows " $CLASSPATH " )
217
288
[ -n " $MAVEN_PROJECTBASEDIR " ] &&
218
- MAVEN_PROJECTBASEDIR=` cygpath --path --windows " $MAVEN_PROJECTBASEDIR " `
289
+ MAVEN_PROJECTBASEDIR=$( cygpath --path --windows " $MAVEN_PROJECTBASEDIR " )
219
290
fi
220
291
292
+ # Provide a "standardized" way to retrieve the CLI args that will
293
+ # work with both Windows and non-Windows executions.
294
+ MAVEN_CMD_LINE_ARGS=" $MAVEN_CONFIG $* "
295
+ export MAVEN_CMD_LINE_ARGS
296
+
221
297
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
222
298
299
+ # shellcheck disable=SC2086 # safe args
223
300
exec " $JAVACMD " \
224
301
$MAVEN_OPTS \
302
+ $MAVEN_DEBUG_OPTS \
225
303
-classpath " $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.jar" \
226
- " -Dmaven.home= ${M2_HOME} " " -Dmaven. multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR} " \
304
+ " -Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR} " \
227
305
${WRAPPER_LAUNCHER} $MAVEN_CONFIG " $@ "
0 commit comments