Nav apraksta

mvnw 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  33. # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
  34. # ----------------------------------------------------------------------------
  35. if [ -z "$MAVEN_SKIP_RC" ] ; then
  36. if [ -f /etc/mavenrc ] ; then
  37. . /etc/mavenrc
  38. fi
  39. if [ -f "$HOME/.mavenrc" ] ; then
  40. . "$HOME/.mavenrc"
  41. fi
  42. fi
  43. # OS specific support. $var _must_ be set to either true or false.
  44. cygwin=false;
  45. darwin=false;
  46. mingw=false
  47. case "`uname`" in
  48. CYGWIN*) cygwin=true ;;
  49. MINGW*) mingw=true;;
  50. Darwin*) darwin=true
  51. #
  52. # Look for the Apple JDKs first to preserve the existing behaviour, and then look
  53. # for the new JDKs provided by Oracle.
  54. #
  55. if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
  56. #
  57. # Apple JDKs
  58. #
  59. export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
  60. fi
  61. if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
  62. #
  63. # Apple JDKs
  64. #
  65. export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
  66. fi
  67. if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
  68. #
  69. # Oracle JDKs
  70. #
  71. export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
  72. fi
  73. if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
  74. #
  75. # Apple JDKs
  76. #
  77. export JAVA_HOME=`/usr/libexec/java_home`
  78. fi
  79. ;;
  80. esac
  81. if [ -z "$JAVA_HOME" ] ; then
  82. if [ -r /etc/gentoo-release ] ; then
  83. JAVA_HOME=`java-config --jre-home`
  84. fi
  85. fi
  86. if [ -z "$M2_HOME" ] ; then
  87. ## resolve links - $0 may be a link to maven's home
  88. PRG="$0"
  89. # need this for relative symlinks
  90. while [ -h "$PRG" ] ; do
  91. ls=`ls -ld "$PRG"`
  92. link=`expr "$ls" : '.*-> \(.*\)$'`
  93. if expr "$link" : '/.*' > /dev/null; then
  94. PRG="$link"
  95. else
  96. PRG="`dirname "$PRG"`/$link"
  97. fi
  98. done
  99. saveddir=`pwd`
  100. M2_HOME=`dirname "$PRG"`/..
  101. # make it fully qualified
  102. M2_HOME=`cd "$M2_HOME" && pwd`
  103. cd "$saveddir"
  104. # echo Using m2 at $M2_HOME
  105. fi
  106. # For Cygwin, ensure paths are in UNIX format before anything is touched
  107. if $cygwin ; then
  108. [ -n "$M2_HOME" ] &&
  109. M2_HOME=`cygpath --unix "$M2_HOME"`
  110. [ -n "$JAVA_HOME" ] &&
  111. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  112. [ -n "$CLASSPATH" ] &&
  113. CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  114. fi
  115. # For Migwn, ensure paths are in UNIX format before anything is touched
  116. if $mingw ; then
  117. [ -n "$M2_HOME" ] &&
  118. M2_HOME="`(cd "$M2_HOME"; pwd)`"
  119. [ -n "$JAVA_HOME" ] &&
  120. JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
  121. # TODO classpath?
  122. fi
  123. if [ -z "$JAVA_HOME" ]; then
  124. javaExecutable="`which javac`"
  125. if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
  126. # readlink(1) is not available as standard on Solaris 10.
  127. readLink=`which readlink`
  128. if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
  129. if $darwin ; then
  130. javaHome="`dirname \"$javaExecutable\"`"
  131. javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
  132. else
  133. javaExecutable="`readlink -f \"$javaExecutable\"`"
  134. fi
  135. javaHome="`dirname \"$javaExecutable\"`"
  136. javaHome=`expr "$javaHome" : '\(.*\)/bin'`
  137. JAVA_HOME="$javaHome"
  138. export JAVA_HOME
  139. fi
  140. fi
  141. fi
  142. if [ -z "$JAVACMD" ] ; then
  143. if [ -n "$JAVA_HOME" ] ; then
  144. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  145. # IBM's JDK on AIX uses strange locations for the executables
  146. JAVACMD="$JAVA_HOME/jre/sh/java"
  147. else
  148. JAVACMD="$JAVA_HOME/bin/java"
  149. fi
  150. else
  151. JAVACMD="`which java`"
  152. fi
  153. fi
  154. if [ ! -x "$JAVACMD" ] ; then
  155. echo "Error: JAVA_HOME is not defined correctly." >&2
  156. echo " We cannot execute $JAVACMD" >&2
  157. exit 1
  158. fi
  159. if [ -z "$JAVA_HOME" ] ; then
  160. echo "Warning: JAVA_HOME environment variable is not set."
  161. fi
  162. CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
  163. # For Cygwin, switch paths to Windows format before running java
  164. if $cygwin; then
  165. [ -n "$M2_HOME" ] &&
  166. M2_HOME=`cygpath --path --windows "$M2_HOME"`
  167. [ -n "$JAVA_HOME" ] &&
  168. JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
  169. [ -n "$CLASSPATH" ] &&
  170. CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  171. fi
  172. # traverses directory structure from process work directory to filesystem root
  173. # first directory with .mvn subdirectory is considered project base directory
  174. find_maven_basedir() {
  175. local basedir=$(pwd)
  176. local wdir=$(pwd)
  177. while [ "$wdir" != '/' ] ; do
  178. if [ -d "$wdir"/.mvn ] ; then
  179. basedir=$wdir
  180. break
  181. fi
  182. wdir=$(cd "$wdir/.."; pwd)
  183. done
  184. echo "${basedir}"
  185. }
  186. # concatenates all lines of a file
  187. concat_lines() {
  188. if [ -f "$1" ]; then
  189. echo "$(tr -s '\n' ' ' < "$1")"
  190. fi
  191. }
  192. export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
  193. MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
  194. # Provide a "standardized" way to retrieve the CLI args that will
  195. # work with both Windows and non-Windows executions.
  196. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
  197. export MAVEN_CMD_LINE_ARGS
  198. WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
  199. exec "$JAVACMD" \
  200. $MAVEN_OPTS \
  201. -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
  202. "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
  203. ${WRAPPER_LAUNCHER} "$@"