/plugins/maven/maven3-server-impl/lib/maven3/bin/mvnDebug

https://bitbucket.org/nbargnesi/idea · Shell · 177 lines · 108 code · 24 blank · 45 comment · 22 complexity · f9b3dd8491fb7492a895d02df2d230b3 MD5 · raw file

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