maven 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #!/bin/sh
  2. # ----------------------------------------------------------------------------
  3. # Copyright 2001-2004 The Apache Software Foundation.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # ----------------------------------------------------------------------------
  17. # Copyright (c) 2001-2002 The Apache Software Foundation. All rights
  18. # reserved.
  19. FOREHEAD_VERSION=1.0-beta-5
  20. if [ -z "$MAVEN_OPTS" ] ; then
  21. MAVEN_OPTS="-Xmx256m"
  22. fi
  23. if [ -f "$HOME/.mavenrc" ] ; then
  24. . "$HOME/.mavenrc"
  25. fi
  26. # OS specific support. $var _must_ be set to either true or false.
  27. cygwin=false;
  28. darwin=false;
  29. case "`uname`" in
  30. CYGWIN*) cygwin=true ;;
  31. Darwin*) darwin=true
  32. if [ -z "$JAVA_VERSION" ] ; then
  33. JAVA_VERSION="CurrentJDK"
  34. else
  35. echo "Using Java version: $JAVA_VERSION"
  36. fi
  37. if [ -z "$JAVA_HOME" ] ; then
  38. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
  39. fi
  40. ;;
  41. esac
  42. # try a couple ways to find MAVEN_HOME
  43. if [ -z ${MAVEN_HOME} ] && [ -d /opt/maven ] ; then
  44. MAVEN_HOME=/opt/maven
  45. fi
  46. if [ -z ${MAVEN_HOME} ] && [ -d "$HOME/maven" ] ; then
  47. MAVEN_HOME="$HOME/maven"
  48. fi
  49. # try to load from env.d file
  50. if [ -z ${MAVEN_HOME} ] && [ -f /etc/env.d/25maven ]; then
  51. MAVEN_HOME=$(source /etc/env.d/25maven; echo ${MAVEN_HOME})
  52. fi
  53. # try to figure it out from how this script was invoked
  54. if [ -z ${MAVEN_HOME} ]; then
  55. ## resolve links - $0 may be a link to maven's home
  56. PRG=$0
  57. progname=`basename $0`
  58. saveddir=`pwd`
  59. # need this for relative symlinks
  60. cd `dirname $PRG`
  61. while [ -h "$PRG" ] ; do
  62. ls=`ls -ld "$PRG"`
  63. link=`expr "$ls" : '.*-> \(.*\)$'`
  64. if expr "$link" : '.*/.*' > /dev/null; then
  65. PRG="$link"
  66. else
  67. PRG="`dirname $PRG`/$link"
  68. fi
  69. done
  70. MAVEN_HOME=`dirname "$PRG"`/..
  71. # make it fully qualified
  72. MAVEN_HOME=`cd "$MAVEN_HOME" && pwd`
  73. cd $saveddir
  74. fi
  75. [ -z "${MAVEN_HOME}" ] && exit "Was unable to determine MAVEN_HOME"
  76. # For Cygwin, ensure paths are in UNIX format before anything is touched
  77. if $cygwin ; then
  78. [ -n "$MAVEN_HOME" ] &&
  79. MAVEN_HOME=`cygpath --unix "$MAVEN_HOME"`
  80. [ -n "$MAVEN_HOME_LOCAL" ] &&
  81. MAVEN_HOME_LOCAL=`cygpath --unix "$MAVEN_HOME_LOCAL"`
  82. [ -n "$JAVA_HOME" ] &&
  83. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  84. [ -n "$CLASSPATH" ] &&
  85. CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  86. fi
  87. if [ -z "$JAVACMD" ] ; then
  88. if [ -n "$JAVA_HOME" ] ; then
  89. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  90. # IBM's JDK on AIX uses strange locations for the executables
  91. JAVACMD="$JAVA_HOME/jre/sh/java"
  92. else
  93. JAVACMD="$JAVA_HOME/bin/java"
  94. fi
  95. else
  96. JAVACMD=java
  97. fi
  98. fi
  99. if [ ! -x "$JAVACMD" ] ; then
  100. echo "Error: JAVA_HOME is not defined correctly."
  101. echo " We cannot execute $JAVACMD"
  102. exit
  103. fi
  104. if [ -z "$JAVA_HOME" ] ; then
  105. echo "Warning: JAVA_HOME environment variable is not set."
  106. echo " If build fails because sun.* classes could not be found"
  107. echo " you will need to set the JAVA_HOME environment variable"
  108. echo " to the installation directory of java."
  109. fi
  110. MAVEN_ENDORSED="${JAVA_HOME}/lib/endorsed:${MAVEN_HOME}/lib/endorsed"
  111. # For Cygwin, switch paths to Windows format before running java
  112. if $cygwin; then
  113. [ -n "$MAVEN_HOME" ] &&
  114. MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"`
  115. [ -n "$MAVEN_HOME_LOCAL" ] &&
  116. MAVEN_HOME_LOCAL=`cygpath --path --windows "$MAVEN_HOME_LOCAL"`
  117. [ -n "$JAVA_HOME" ] &&
  118. JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
  119. [ -n "$HOME" ] &&
  120. HOME=`cygpath --path --windows "$HOME"`
  121. [ -n "$MAVEN_ENDORSED" ] &&
  122. MAVEN_ENDORSED=`cygpath --path --windows "$MAVEN_ENDORSED"`
  123. fi
  124. # For Darwin, use classes.jar for TOOLS_JAR
  125. TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
  126. if $darwin; then
  127. TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar"
  128. fi
  129. MAIN_CLASS=com.werken.forehead.Forehead
  130. if [ -n "$MAVEN_HOME_LOCAL" ]; then
  131. MAVEN_OPTS="$MAVEN_OPTS -Dmaven.home.local=${MAVEN_HOME_LOCAL}"
  132. fi
  133. "$JAVACMD" \
  134. $MAVEN_OPTS \
  135. -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
  136. -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
  137. "-Djava.endorsed.dirs=${MAVEN_ENDORSED}" \
  138. -classpath "${MAVEN_HOME}/lib/forehead-${FOREHEAD_VERSION}.jar" \
  139. "-Dforehead.conf.file=${MAVEN_HOME}/bin/forehead.conf" \
  140. "-Dtools.jar=$TOOLS_JAR" \
  141. "-Dmaven.home=${MAVEN_HOME}" \
  142. $MAIN_CLASS "$@"