2 # ----------------------------------------------------------------------------
\r
3 # Licensed to the Apache Software Foundation (ASF) under one
\r
4 # or more contributor license agreements. See the NOTICE file
\r
5 # distributed with this work for additional information
\r
6 # regarding copyright ownership. The ASF licenses this file
\r
7 # to you under the Apache License, Version 2.0 (the
\r
8 # "License"); you may not use this file except in compliance
\r
9 # with the License. You may obtain a copy of the License at
\r
11 # http://www.apache.org/licenses/LICENSE-2.0
\r
13 # Unless required by applicable law or agreed to in writing,
\r
14 # software distributed under the License is distributed on an
\r
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
16 # KIND, either express or implied. See the License for the
\r
17 # specific language governing permissions and limitations
\r
18 # under the License.
\r
19 # ----------------------------------------------------------------------------
\r
21 # ----------------------------------------------------------------------------
\r
22 # Maven2 Start Up Batch script
\r
24 # Required ENV vars:
\r
25 # ------------------
\r
26 # JAVA_HOME - location of a JDK home dir
\r
30 # M2_HOME - location of maven2's installed home dir
\r
31 # MAVEN_OPTS - parameters passed to the Java VM when running Maven
\r
32 # e.g. to debug Maven itself, use
\r
33 # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
\r
34 # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
\r
35 # ----------------------------------------------------------------------------
\r
37 if [ -z "$MAVEN_SKIP_RC" ] ; then
\r
39 if [ -f /etc/mavenrc ] ; then
\r
43 if [ -f "$HOME/.mavenrc" ] ; then
\r
49 # OS specific support. $var _must_ be set to either true or false.
\r
54 CYGWIN*) cygwin=true ;;
\r
55 MINGW*) mingw=true;;
\r
56 Darwin*) darwin=true
\r
57 # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
\r
58 # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
\r
59 if [ -z "$JAVA_HOME" ]; then
\r
60 if [ -x "/usr/libexec/java_home" ]; then
\r
61 export JAVA_HOME="`/usr/libexec/java_home`"
\r
63 export JAVA_HOME="/Library/Java/Home"
\r
69 if [ -z "$JAVA_HOME" ] ; then
\r
70 if [ -r /etc/gentoo-release ] ; then
\r
71 JAVA_HOME=`java-config --jre-home`
\r
75 if [ -z "$M2_HOME" ] ; then
\r
76 ## resolve links - $0 may be a link to maven's home
\r
79 # need this for relative symlinks
\r
80 while [ -h "$PRG" ] ; do
\r
82 link=`expr "$ls" : '.*-> \(.*\)$'`
\r
83 if expr "$link" : '/.*' > /dev/null; then
\r
86 PRG="`dirname "$PRG"`/$link"
\r
92 M2_HOME=`dirname "$PRG"`/..
\r
94 # make it fully qualified
\r
95 M2_HOME=`cd "$M2_HOME" && pwd`
\r
98 # echo Using m2 at $M2_HOME
\r
101 # For Cygwin, ensure paths are in UNIX format before anything is touched
\r
103 [ -n "$M2_HOME" ] &&
\r
104 M2_HOME=`cygpath --unix "$M2_HOME"`
\r
105 [ -n "$JAVA_HOME" ] &&
\r
106 JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
\r
107 [ -n "$CLASSPATH" ] &&
\r
108 CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
\r
111 # For Migwn, ensure paths are in UNIX format before anything is touched
\r
113 [ -n "$M2_HOME" ] &&
\r
114 M2_HOME="`(cd "$M2_HOME"; pwd)`"
\r
115 [ -n "$JAVA_HOME" ] &&
\r
116 JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
\r
120 if [ -z "$JAVA_HOME" ]; then
\r
121 javaExecutable="`which javac`"
\r
122 if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
\r
123 # readlink(1) is not available as standard on Solaris 10.
\r
124 readLink=`which readlink`
\r
125 if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
\r
127 javaHome="`dirname \"$javaExecutable\"`"
\r
128 javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
\r
130 javaExecutable="`readlink -f \"$javaExecutable\"`"
\r
132 javaHome="`dirname \"$javaExecutable\"`"
\r
133 javaHome=`expr "$javaHome" : '\(.*\)/bin'`
\r
134 JAVA_HOME="$javaHome"
\r
140 if [ -z "$JAVACMD" ] ; then
\r
141 if [ -n "$JAVA_HOME" ] ; then
\r
142 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
\r
143 # IBM's JDK on AIX uses strange locations for the executables
\r
144 JAVACMD="$JAVA_HOME/jre/sh/java"
\r
146 JAVACMD="$JAVA_HOME/bin/java"
\r
149 JAVACMD="`which java`"
\r
153 if [ ! -x "$JAVACMD" ] ; then
\r
154 echo "Error: JAVA_HOME is not defined correctly." >&2
\r
155 echo " We cannot execute $JAVACMD" >&2
\r
159 if [ -z "$JAVA_HOME" ] ; then
\r
160 echo "Warning: JAVA_HOME environment variable is not set."
\r
163 CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
\r
165 # traverses directory structure from process work directory to filesystem root
\r
166 # first directory with .mvn subdirectory is considered project base directory
\r
167 find_maven_basedir() {
\r
171 echo "Path not specified to find_maven_basedir"
\r
177 while [ "$wdir" != '/' ] ; do
\r
178 if [ -d "$wdir"/.mvn ] ; then
\r
182 # workaround for JBEAP-8937 (on Solaris 10/Sparc)
\r
183 if [ -d "${wdir}" ]; then
\r
184 wdir=`cd "$wdir/.."; pwd`
\r
186 # end of workaround
\r
191 # concatenates all lines of a file
\r
193 if [ -f "$1" ]; then
\r
194 echo "$(tr -s '\n' ' ' < "$1")"
\r
198 BASE_DIR=`find_maven_basedir "$(pwd)"`
\r
199 if [ -z "$BASE_DIR" ]; then
\r
203 export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
\r
204 echo $MAVEN_PROJECTBASEDIR
\r
205 MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
\r
207 # For Cygwin, switch paths to Windows format before running java
\r
209 [ -n "$M2_HOME" ] &&
\r
210 M2_HOME=`cygpath --path --windows "$M2_HOME"`
\r
211 [ -n "$JAVA_HOME" ] &&
\r
212 JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
\r
213 [ -n "$CLASSPATH" ] &&
\r
214 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
\r
215 [ -n "$MAVEN_PROJECTBASEDIR" ] &&
\r
216 MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
\r
219 WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
\r
223 -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
\r
224 "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
\r
225 ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
\r