Ejemplo de aplicación con security user/password
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
10 KiB

  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. # https://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. # Maven 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 /usr/local/etc/mavenrc ] ; then
  37. . /usr/local/etc/mavenrc
  38. fi
  39. if [ -f /etc/mavenrc ] ; then
  40. . /etc/mavenrc
  41. fi
  42. if [ -f "$HOME/.mavenrc" ] ; then
  43. . "$HOME/.mavenrc"
  44. fi
  45. fi
  46. # OS specific support. $var _must_ be set to either true or false.
  47. cygwin=false;
  48. darwin=false;
  49. mingw=false
  50. case "`uname`" in
  51. CYGWIN*) cygwin=true ;;
  52. MINGW*) mingw=true;;
  53. Darwin*) darwin=true
  54. # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
  55. # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
  56. if [ -z "$JAVA_HOME" ]; then
  57. if [ -x "/usr/libexec/java_home" ]; then
  58. export JAVA_HOME="`/usr/libexec/java_home`"
  59. else
  60. export JAVA_HOME="/Library/Java/Home"
  61. fi
  62. fi
  63. ;;
  64. esac
  65. if [ -z "$JAVA_HOME" ] ; then
  66. if [ -r /etc/gentoo-release ] ; then
  67. JAVA_HOME=`java-config --jre-home`
  68. fi
  69. fi
  70. if [ -z "$M2_HOME" ] ; then
  71. ## resolve links - $0 may be a link to maven's home
  72. PRG="$0"
  73. # need this for relative symlinks
  74. while [ -h "$PRG" ] ; do
  75. ls=`ls -ld "$PRG"`
  76. link=`expr "$ls" : '.*-> \(.*\)$'`
  77. if expr "$link" : '/.*' > /dev/null; then
  78. PRG="$link"
  79. else
  80. PRG="`dirname "$PRG"`/$link"
  81. fi
  82. done
  83. saveddir=`pwd`
  84. M2_HOME=`dirname "$PRG"`/..
  85. # make it fully qualified
  86. M2_HOME=`cd "$M2_HOME" && pwd`
  87. cd "$saveddir"
  88. # echo Using m2 at $M2_HOME
  89. fi
  90. # For Cygwin, ensure paths are in UNIX format before anything is touched
  91. if $cygwin ; then
  92. [ -n "$M2_HOME" ] &&
  93. M2_HOME=`cygpath --unix "$M2_HOME"`
  94. [ -n "$JAVA_HOME" ] &&
  95. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  96. [ -n "$CLASSPATH" ] &&
  97. CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  98. fi
  99. # For Mingw, ensure paths are in UNIX format before anything is touched
  100. if $mingw ; then
  101. [ -n "$M2_HOME" ] &&
  102. M2_HOME="`(cd "$M2_HOME"; pwd)`"
  103. [ -n "$JAVA_HOME" ] &&
  104. JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
  105. fi
  106. if [ -z "$JAVA_HOME" ]; then
  107. javaExecutable="`which javac`"
  108. if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
  109. # readlink(1) is not available as standard on Solaris 10.
  110. readLink=`which readlink`
  111. if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
  112. if $darwin ; then
  113. javaHome="`dirname \"$javaExecutable\"`"
  114. javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
  115. else
  116. javaExecutable="`readlink -f \"$javaExecutable\"`"
  117. fi
  118. javaHome="`dirname \"$javaExecutable\"`"
  119. javaHome=`expr "$javaHome" : '\(.*\)/bin'`
  120. JAVA_HOME="$javaHome"
  121. export JAVA_HOME
  122. fi
  123. fi
  124. fi
  125. if [ -z "$JAVACMD" ] ; then
  126. if [ -n "$JAVA_HOME" ] ; then
  127. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  128. # IBM's JDK on AIX uses strange locations for the executables
  129. JAVACMD="$JAVA_HOME/jre/sh/java"
  130. else
  131. JAVACMD="$JAVA_HOME/bin/java"
  132. fi
  133. else
  134. JAVACMD="`\\unset -f command; \\command -v java`"
  135. fi
  136. fi
  137. if [ ! -x "$JAVACMD" ] ; then
  138. echo "Error: JAVA_HOME is not defined correctly." >&2
  139. echo " We cannot execute $JAVACMD" >&2
  140. exit 1
  141. fi
  142. if [ -z "$JAVA_HOME" ] ; then
  143. echo "Warning: JAVA_HOME environment variable is not set."
  144. fi
  145. CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
  146. # traverses directory structure from process work directory to filesystem root
  147. # first directory with .mvn subdirectory is considered project base directory
  148. find_maven_basedir() {
  149. if [ -z "$1" ]
  150. then
  151. echo "Path not specified to find_maven_basedir"
  152. return 1
  153. fi
  154. basedir="$1"
  155. wdir="$1"
  156. while [ "$wdir" != '/' ] ; do
  157. if [ -d "$wdir"/.mvn ] ; then
  158. basedir=$wdir
  159. break
  160. fi
  161. # workaround for JBEAP-8937 (on Solaris 10/Sparc)
  162. if [ -d "${wdir}" ]; then
  163. wdir=`cd "$wdir/.."; pwd`
  164. fi
  165. # end of workaround
  166. done
  167. echo "${basedir}"
  168. }
  169. # concatenates all lines of a file
  170. concat_lines() {
  171. if [ -f "$1" ]; then
  172. echo "$(tr -s '\n' ' ' < "$1")"
  173. fi
  174. }
  175. BASE_DIR=`find_maven_basedir "$(pwd)"`
  176. if [ -z "$BASE_DIR" ]; then
  177. exit 1;
  178. fi
  179. ##########################################################################################
  180. # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
  181. # This allows using the maven wrapper in projects that prohibit checking in binary data.
  182. ##########################################################################################
  183. if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
  184. if [ "$MVNW_VERBOSE" = true ]; then
  185. echo "Found .mvn/wrapper/maven-wrapper.jar"
  186. fi
  187. else
  188. if [ "$MVNW_VERBOSE" = true ]; then
  189. echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
  190. fi
  191. if [ -n "$MVNW_REPOURL" ]; then
  192. jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
  193. else
  194. jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
  195. fi
  196. while IFS="=" read key value; do
  197. case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
  198. esac
  199. done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
  200. if [ "$MVNW_VERBOSE" = true ]; then
  201. echo "Downloading from: $jarUrl"
  202. fi
  203. wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
  204. if $cygwin; then
  205. wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
  206. fi
  207. if command -v wget > /dev/null; then
  208. if [ "$MVNW_VERBOSE" = true ]; then
  209. echo "Found wget ... using wget"
  210. fi
  211. if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
  212. wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
  213. else
  214. wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
  215. fi
  216. elif command -v curl > /dev/null; then
  217. if [ "$MVNW_VERBOSE" = true ]; then
  218. echo "Found curl ... using curl"
  219. fi
  220. if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
  221. curl -o "$wrapperJarPath" "$jarUrl" -f
  222. else
  223. curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
  224. fi
  225. else
  226. if [ "$MVNW_VERBOSE" = true ]; then
  227. echo "Falling back to using Java to download"
  228. fi
  229. javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
  230. # For Cygwin, switch paths to Windows format before running javac
  231. if $cygwin; then
  232. javaClass=`cygpath --path --windows "$javaClass"`
  233. fi
  234. if [ -e "$javaClass" ]; then
  235. if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
  236. if [ "$MVNW_VERBOSE" = true ]; then
  237. echo " - Compiling MavenWrapperDownloader.java ..."
  238. fi
  239. # Compiling the Java class
  240. ("$JAVA_HOME/bin/javac" "$javaClass")
  241. fi
  242. if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
  243. # Running the downloader
  244. if [ "$MVNW_VERBOSE" = true ]; then
  245. echo " - Running MavenWrapperDownloader.java ..."
  246. fi
  247. ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
  248. fi
  249. fi
  250. fi
  251. fi
  252. ##########################################################################################
  253. # End of extension
  254. ##########################################################################################
  255. export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
  256. if [ "$MVNW_VERBOSE" = true ]; then
  257. echo $MAVEN_PROJECTBASEDIR
  258. fi
  259. MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
  260. # For Cygwin, switch paths to Windows format before running java
  261. if $cygwin; then
  262. [ -n "$M2_HOME" ] &&
  263. M2_HOME=`cygpath --path --windows "$M2_HOME"`
  264. [ -n "$JAVA_HOME" ] &&
  265. JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
  266. [ -n "$CLASSPATH" ] &&
  267. CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  268. [ -n "$MAVEN_PROJECTBASEDIR" ] &&
  269. MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
  270. fi
  271. # Provide a "standardized" way to retrieve the CLI args that will
  272. # work with both Windows and non-Windows executions.
  273. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
  274. export MAVEN_CMD_LINE_ARGS
  275. WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
  276. exec "$JAVACMD" \
  277. $MAVEN_OPTS \
  278. $MAVEN_DEBUG_OPTS \
  279. -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
  280. "-Dmaven.home=${M2_HOME}" \
  281. "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
  282. ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"