1
- #! /bin/bash
1
+ #! /bin/sh
2
2
# ----------------------------------------------------------------------------
3
3
# Licensed to the Apache Software Foundation (ASF) under one
4
4
# or more contributor license agreements. See the NOTICE file
19
19
# ----------------------------------------------------------------------------
20
20
21
21
# ----------------------------------------------------------------------------
22
- # Maven2 Start Up Batch script
22
+ # Maven Start Up Batch script
23
23
#
24
24
# Required ENV vars:
25
25
# ------------------
@@ -54,38 +54,16 @@ case "`uname`" in
54
54
CYGWIN* ) cygwin=true ;;
55
55
MINGW* ) mingw=true;;
56
56
Darwin* ) darwin=true
57
- #
58
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
59
- # for the new JDKs provided by Oracle.
60
- #
61
- if [ -z " $JAVA_HOME " ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62
- #
63
- # Apple JDKs
64
- #
65
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66
- fi
67
-
68
- if [ -z " $JAVA_HOME " ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69
- #
70
- # Apple JDKs
71
- #
72
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73
- fi
74
-
75
- if [ -z " $JAVA_HOME " ] && [ -L " /Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76
- #
77
- # Oracle JDKs
78
- #
79
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80
- fi
81
-
82
- if [ -z " $JAVA_HOME " ] && [ -x " /usr/libexec/java_home" ]; then
83
- #
84
- # Apple JDKs
85
- #
86
- export JAVA_HOME=` /usr/libexec/java_home`
87
- fi
88
- ;;
57
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59
+ if [ -z " $JAVA_HOME " ]; then
60
+ if [ -x " /usr/libexec/java_home" ]; then
61
+ export JAVA_HOME=" ` /usr/libexec/java_home` "
62
+ else
63
+ export JAVA_HOME=" /Library/Java/Home"
64
+ fi
65
+ fi
66
+ ;;
89
67
esac
90
68
91
69
if [ -z " $JAVA_HOME " ] ; then
@@ -130,13 +108,12 @@ if $cygwin ; then
130
108
CLASSPATH=` cygpath --path --unix " $CLASSPATH " `
131
109
fi
132
110
133
- # For Migwn , ensure paths are in UNIX format before anything is touched
111
+ # For Mingw , ensure paths are in UNIX format before anything is touched
134
112
if $mingw ; then
135
113
[ -n " $M2_HOME " ] &&
136
114
M2_HOME=" ` (cd " $M2_HOME " ; pwd)` "
137
115
[ -n " $JAVA_HOME " ] &&
138
116
JAVA_HOME=" ` (cd " $JAVA_HOME " ; pwd)` "
139
- # TODO classpath?
140
117
fi
141
118
142
119
if [ -z " $JAVA_HOME " ]; then
@@ -187,14 +164,25 @@ CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
187
164
# traverses directory structure from process work directory to filesystem root
188
165
# first directory with .mvn subdirectory is considered project base directory
189
166
find_maven_basedir () {
190
- local basedir=$( pwd)
191
- local wdir=$( pwd)
167
+
168
+ if [ -z " $1 " ]
169
+ then
170
+ echo " Path not specified to find_maven_basedir"
171
+ return 1
172
+ fi
173
+
174
+ basedir=" $1 "
175
+ wdir=" $1 "
192
176
while [ " $wdir " != ' /' ] ; do
193
177
if [ -d " $wdir " /.mvn ] ; then
194
178
basedir=$wdir
195
179
break
196
180
fi
197
- wdir=$( cd " $wdir /.." ; pwd)
181
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
182
+ if [ -d " ${wdir} " ]; then
183
+ wdir=` cd " $wdir /.." ; pwd`
184
+ fi
185
+ # end of workaround
198
186
done
199
187
echo " ${basedir} "
200
188
}
@@ -206,7 +194,94 @@ concat_lines() {
206
194
fi
207
195
}
208
196
209
- export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:- $(find_maven_basedir)}
197
+ BASE_DIR=` find_maven_basedir " $( pwd) " `
198
+ if [ -z " $BASE_DIR " ]; then
199
+ exit 1;
200
+ fi
201
+
202
+ # #########################################################################################
203
+ # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
204
+ # This allows using the maven wrapper in projects that prohibit checking in binary data.
205
+ # #########################################################################################
206
+ if [ -r " $BASE_DIR /.mvn/wrapper/maven-wrapper.jar" ]; then
207
+ if [ " $MVNW_VERBOSE " = true ]; then
208
+ echo " Found .mvn/wrapper/maven-wrapper.jar"
209
+ fi
210
+ else
211
+ if [ " $MVNW_VERBOSE " = true ]; then
212
+ echo " Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213
+ fi
214
+ if [ -n " $MVNW_REPOURL " ]; then
215
+ jarUrl=" $MVNW_REPOURL /io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216
+ else
217
+ jarUrl=" https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218
+ fi
219
+ while IFS=" =" read key value; do
220
+ case " $key " in (wrapperUrl) jarUrl=" $value " ; break ;;
221
+ esac
222
+ done < " $BASE_DIR /.mvn/wrapper/maven-wrapper.properties"
223
+ if [ " $MVNW_VERBOSE " = true ]; then
224
+ echo " Downloading from: $jarUrl "
225
+ fi
226
+ wrapperJarPath=" $BASE_DIR /.mvn/wrapper/maven-wrapper.jar"
227
+ if $cygwin ; then
228
+ wrapperJarPath=` cygpath --path --windows " $wrapperJarPath " `
229
+ fi
230
+
231
+ if command -v wget > /dev/null; then
232
+ if [ " $MVNW_VERBOSE " = true ]; then
233
+ echo " Found wget ... using wget"
234
+ fi
235
+ if [ -z " $MVNW_USERNAME " ] || [ -z " $MVNW_PASSWORD " ]; then
236
+ wget " $jarUrl " -O " $wrapperJarPath "
237
+ else
238
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD " $jarUrl " -O " $wrapperJarPath "
239
+ fi
240
+ elif command -v curl > /dev/null; then
241
+ if [ " $MVNW_VERBOSE " = true ]; then
242
+ echo " Found curl ... using curl"
243
+ fi
244
+ if [ -z " $MVNW_USERNAME " ] || [ -z " $MVNW_PASSWORD " ]; then
245
+ curl -o " $wrapperJarPath " " $jarUrl " -f
246
+ else
247
+ curl --user $MVNW_USERNAME :$MVNW_PASSWORD -o " $wrapperJarPath " " $jarUrl " -f
248
+ fi
249
+
250
+ else
251
+ if [ " $MVNW_VERBOSE " = true ]; then
252
+ echo " Falling back to using Java to download"
253
+ fi
254
+ javaClass=" $BASE_DIR /.mvn/wrapper/MavenWrapperDownloader.java"
255
+ # For Cygwin, switch paths to Windows format before running javac
256
+ if $cygwin ; then
257
+ javaClass=` cygpath --path --windows " $javaClass " `
258
+ fi
259
+ if [ -e " $javaClass " ]; then
260
+ if [ ! -e " $BASE_DIR /.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261
+ if [ " $MVNW_VERBOSE " = true ]; then
262
+ echo " - Compiling MavenWrapperDownloader.java ..."
263
+ fi
264
+ # Compiling the Java class
265
+ (" $JAVA_HOME /bin/javac" " $javaClass " )
266
+ fi
267
+ if [ -e " $BASE_DIR /.mvn/wrapper/MavenWrapperDownloader.class" ]; then
268
+ # Running the downloader
269
+ if [ " $MVNW_VERBOSE " = true ]; then
270
+ echo " - Running MavenWrapperDownloader.java ..."
271
+ fi
272
+ (" $JAVA_HOME /bin/java" -cp .mvn/wrapper MavenWrapperDownloader " $MAVEN_PROJECTBASEDIR " )
273
+ fi
274
+ fi
275
+ fi
276
+ fi
277
+ # #########################################################################################
278
+ # End of extension
279
+ # #########################################################################################
280
+
281
+ export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:- " $BASE_DIR " }
282
+ if [ " $MVNW_VERBOSE " = true ]; then
283
+ echo $MAVEN_PROJECTBASEDIR
284
+ fi
210
285
MAVEN_OPTS=" $( concat_lines " $MAVEN_PROJECTBASEDIR /.mvn/jvm.config" ) $MAVEN_OPTS "
211
286
212
287
# For Cygwin, switch paths to Windows format before running java
@@ -228,7 +303,6 @@ export MAVEN_CMD_LINE_ARGS
228
303
229
304
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
230
305
231
- # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@
232
306
exec " $JAVACMD " \
233
307
$MAVEN_OPTS \
234
308
-classpath " $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.jar" \
0 commit comments