| 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 |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 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 | # ---------------------------------------------------------------------------- |
| 20 | |
| 21 | # ---------------------------------------------------------------------------- |
| 22 | # Maven2 Start Up Batch script |
| 23 | # |
| 24 | # Required ENV vars: |
| 25 | # ------------------ |
| 26 | # JAVA_HOME - location of a JDK home dir |
| 27 | # |
| 28 | # Optional ENV vars |
| 29 | # ----------------- |
| 30 | # M2_HOME - location of maven2's installed home dir |
| 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven |
| 32 | # e.g. to debug Maven itself, use |
| 33 | # set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
| 34 | # ---------------------------------------------------------------------------- |
| 35 | |
| 36 | # OS specific support. $var _must_ be set to either true or false. |
| 37 | cygwin=false; |
| 38 | darwin=false; |
| 39 | mingw=false |
| 40 | case "`uname`" in |
| 41 | CYGWIN*) cygwin=true ;; |
| 42 | MINGW*) mingw=true;; |
| 43 | Darwin*) darwin=true |
| 44 | if [ -z "$JAVA_VERSION" ] ; then |
| 45 | JAVA_VERSION="CurrentJDK" |
| 46 | else |
| 47 | echo "Using Java version: $JAVA_VERSION" |
| 48 | fi |
| 49 | if [ -z "$JAVA_HOME" ] ; then |
| 50 | JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home |
| 51 | fi |
| 52 | ;; |
| 53 | esac |
| 54 | |
| 55 | if [ -z "$JAVA_HOME" ] ; then |
| 56 | if [ -r /etc/gentoo-release ] ; then |
| 57 | JAVA_HOME=`java-config --jre-home` |
| 58 | fi |
| 59 | fi |
| 60 | |
| 61 | if [ -z "$M2_HOME" ] ; then |
| 62 | ## resolve links - $0 may be a link to maven's home |
| 63 | PRG="$0" |
| 64 | |
| 65 | # need this for relative symlinks |
| 66 | while [ -h "$PRG" ] ; do |
| 67 | ls=`ls -ld "$PRG"` |
| 68 | link=`expr "$ls" : '.*-> \(.*\)$'` |
| 69 | if expr "$link" : '/.*' > /dev/null; then |
| 70 | PRG="$link" |
| 71 | else |
| 72 | PRG="`dirname "$PRG"`/$link" |
| 73 | fi |
| 74 | done |
| 75 | |
| 76 | saveddir=`pwd` |
| 77 | |
| 78 | M2_HOME=`dirname "$PRG"`/.. |
| 79 | |
| 80 | # make it fully qualified |
| 81 | M2_HOME=`cd "$M2_HOME" && pwd` |
| 82 | |
| 83 | cd "$saveddir" |
| 84 | # echo Using m2 at $M2_HOME |
| 85 | fi |
| 86 | |
| 87 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
| 88 | if $cygwin ; then |
| 89 | [ -n "$M2_HOME" ] && |
| 90 | M2_HOME=`cygpath --unix "$M2_HOME"` |
| 91 | [ -n "$JAVA_HOME" ] && |
| 92 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` |
| 93 | [ -n "$CLASSPATH" ] && |
| 94 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` |
| 95 | fi |
| 96 | |
| 97 | # For Migwn, ensure paths are in UNIX format before anything is touched |
| 98 | if $mingw ; then |
| 99 | [ -n "$M2_HOME" ] && |
| 100 | M2_HOME="`(cd "$M2_HOME"; pwd)`" |
| 101 | [ -n "$JAVA_HOME" ] && |
| 102 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" |
| 103 | # TODO classpath? |
| 104 | fi |
| 105 | |
| 106 | if [ -z "$JAVACMD" ] ; then |
| 107 | if [ -n "$JAVA_HOME" ] ; then |
| 108 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
| 109 | # IBM's JDK on AIX uses strange locations for the executables |
| 110 | JAVACMD="$JAVA_HOME/jre/sh/java" |
| 111 | else |
| 112 | JAVACMD="$JAVA_HOME/bin/java" |
| 113 | fi |
| 114 | else |
| 115 | JAVACMD="`which java`" |
| 116 | fi |
| 117 | fi |
| 118 | |
| 119 | if [ ! -x "$JAVACMD" ] ; then |
| 120 | echo "Error: JAVA_HOME is not defined correctly." |
| 121 | echo " We cannot execute $JAVACMD" |
| 122 | exit 1 |
| 123 | fi |
| 124 | |
| 125 | if [ -z "$JAVA_HOME" ] ; then |
| 126 | echo "Warning: JAVA_HOME environment variable is not set." |
| 127 | fi |
| 128 | |
| 129 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher |
| 130 | |
| 131 | # For Cygwin, switch paths to Windows format before running java |
| 132 | if $cygwin; then |
| 133 | [ -n "$M2_HOME" ] && |
| 134 | M2_HOME=`cygpath --path --windows "$M2_HOME"` |
| 135 | [ -n "$JAVA_HOME" ] && |
| 136 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` |
| 137 | [ -n "$HOME" ] && |
| 138 | HOME=`cygpath --path --windows "$HOME"` |
| 139 | fi |
| 140 | |
| 141 | exec "$JAVACMD" \ |
| 142 | $MAVEN_OPTS \ |
| 143 | -classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \ |
| 144 | "-Dclassworlds.conf=${M2_HOME}/bin/translate.conf" \ |
| 145 | "-Dmaven.home=${M2_HOME}" \ |
| 146 | ${CLASSWORLDS_LAUNCHER} "$@" |
| 147 | |
| 148 |