Statistics
| Revision:

root / trunk / build / maven / bin / mvnDebug @ 20506

History | View | Annotate | Download (4.62 KB)

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
INT_MAVEN_OPTS="$MAVEN_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
37

    
38
echo Preparing to Execute Maven in Debug Mode
39

    
40
QUOTED_ARGS=""
41
while [ "$1" != "" ] ; do
42

    
43
  QUOTED_ARGS="$QUOTED_ARGS \"$1\""
44
  shift
45

    
46
done
47

    
48
if [ -f /etc/mavenrc ] ; then
49
  . /etc/mavenrc
50
fi
51

    
52
if [ -f "$HOME/.mavenrc" ] ; then
53
  . "$HOME/.mavenrc"
54
fi
55

    
56
# OS specific support.  $var _must_ be set to either true or false.
57
cygwin=false;
58
darwin=false;
59
mingw=false
60
case "`uname`" in
61
  CYGWIN*) cygwin=true ;;
62
  MINGW*) mingw=true;;
63
  Darwin*) darwin=true 
64
           if [ -z "$JAVA_VERSION" ] ; then
65
             JAVA_VERSION="CurrentJDK"
66
           else
67
             echo "Using Java version: $JAVA_VERSION"
68
           fi
69
           if [ -z "$JAVA_HOME" ] ; then
70
             JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
71
           fi
72
           ;;
73
esac
74

    
75
if [ -z "$JAVA_HOME" ] ; then
76
  if [ -r /etc/gentoo-release ] ; then
77
    JAVA_HOME=`java-config --jre-home`
78
  fi
79
fi
80

    
81
if [ -z "$M2_HOME" ] ; then
82
  ## resolve links - $0 may be a link to maven's home
83
  PRG="$0"
84

    
85
  # need this for relative symlinks
86
  while [ -h "$PRG" ] ; do
87
    ls=`ls -ld "$PRG"`
88
    link=`expr "$ls" : '.*-> \(.*\)$'`
89
    if expr "$link" : '/.*' > /dev/null; then
90
      PRG="$link"
91
    else
92
      PRG="`dirname "$PRG"`/$link"
93
    fi
94
  done
95

    
96
  saveddir=`pwd`
97

    
98
  M2_HOME=`dirname "$PRG"`/..
99

    
100
  # make it fully qualified
101
  M2_HOME=`cd "$M2_HOME" && pwd`
102

    
103
  cd "$saveddir"
104
  # echo Using m2 at $M2_HOME
105
fi
106

    
107
# For Cygwin, ensure paths are in UNIX format before anything is touched
108
if $cygwin ; then
109
  [ -n "$M2_HOME" ] &&
110
    M2_HOME=`cygpath --unix "$M2_HOME"`
111
  [ -n "$JAVA_HOME" ] &&
112
    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
113
  [ -n "$CLASSPATH" ] &&
114
    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
115
fi
116

    
117
# For Migwn, ensure paths are in UNIX format before anything is touched
118
if $mingw ; then
119
  [ -n "$M2_HOME" ] &&
120
    M2_HOME="`(cd "$M2_HOME"; pwd)`"
121
  [ -n "$JAVA_HOME" ] &&
122
    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
123
  # TODO classpath?
124
fi
125

    
126
if [ -z "$JAVACMD" ] ; then
127
  if [ -n "$JAVA_HOME"  ] ; then
128
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
129
      # IBM's JDK on AIX uses strange locations for the executables
130
      JAVACMD="$JAVA_HOME/jre/sh/java"
131
    else
132
      JAVACMD="$JAVA_HOME/bin/java"
133
    fi
134
  else
135
    JAVACMD=java
136
  fi
137
fi
138

    
139
if [ ! -x "$JAVACMD" ] ; then
140
  echo "Error: JAVA_HOME is not defined correctly."
141
  echo "  We cannot execute $JAVACMD"
142
  exit 1
143
fi
144

    
145
if [ -z "$JAVA_HOME" ] ; then
146
  echo "Warning: JAVA_HOME environment variable is not set."
147
fi
148

    
149
CLASSWORLDS_LAUNCHER=org.codehaus.classworlds.Launcher
150

    
151
# For Cygwin, switch paths to Windows format before running java
152
if $cygwin; then
153
  [ -n "$M2_HOME" ] &&
154
    M2_HOME=`cygpath --path --windows "$M2_HOME"`
155
  [ -n "$JAVA_HOME" ] &&
156
    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
157
  [ -n "$HOME" ] &&
158
    HOME=`cygpath --path --windows "$HOME"`
159
fi
160

    
161
exec "$JAVACMD" \
162
  $INT_MAVEN_OPTS \
163
  -classpath "${M2_HOME}"/boot/classworlds-*.jar \
164
  "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
165
  "-Dmaven.home=${M2_HOME}"  \
166
  ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
167

    
168