Blame | Last modification | View Log | RSS feed
#! /bin/sh# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.# Extract launch and ant arguments, (see details below).ant_exec_args=no_config=falseuse_jikes_default=falseant_exec_debug=falseshow_help=falseif [ -z "$PROTECT_NL" ]; thenPROTECT_NL=trueos=`uname -s`rel=`uname -r`# heirloom bourne-shell used by Solaris 10 is not POSIX# it lacks features necessary to protect trailing NL from subshell trimmingif [ "$os" = SunOS -a "$rel" = "5.10" ]; thenPROTECT_NL=falsefififor arg in "$@"; doif [ "$arg" = "--noconfig" ]; thenno_config=trueelif [ "$arg" = "--usejikes" ]; thenuse_jikes_default=trueelif [ "$arg" = "--execdebug" ]; thenant_exec_debug=trueelif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ]; thenshow_help=trueant_exec_args="$ant_exec_args -h"elseif [ my"$arg" = my"-h" -o my"$arg" = my"-help" ]; thenshow_help=truefiif [ "$PROTECT_NL" = "true" ]; then# pad the value with X to protect trailing NLs from subshell output trimmingesc_arg="${arg}X"elseesc_arg="${arg}"fi# wrap all arguments as "" strings, escape any internal back-slash, double-quote, $, or back-tick characters# use printf to avoid echo interpretation behaviors such as escapes and line continuation# Mac bsd_sed does not support group-0, so pattern uses group-1# Solaris sed only processes lines with trailing newline, passing in an extra newline# subshell (heirloom and posix) will trim the added trailing newlineesc_arg="`printf '%s\n' "$esc_arg" | sed -e 's@\([$\"\`\\]\)@\\\\\\1@g' `"if [ "$PROTECT_NL" = "true" ]; then# remove the padding X added above, this syntax is POSIX compatible but not heirloom-shesc_arg="${esc_arg%X}"fiquoted_arg="\"$esc_arg\""if $ant_exec_debug; then# using printf to avoid echo line continuation and escape interpretationprintf "arg : %s\n" "$arg"printf "quoted_arg: %s\n" "$quoted_arg"fiant_exec_args="$ant_exec_args $quoted_arg"fidone# Source/default ant configurationif $no_config; thenrpm_mode=falseusejikes=$use_jikes_defaultelse# load system-wide ant configuration (ONLY if ANT_HOME has NOT been set)if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; thenif [ -f "/etc/ant.conf" ]; then. /etc/ant.conffifi# load user ant configurationif [ -f "$HOME/.ant/ant.conf" ]; then. $HOME/.ant/ant.conffiif [ -f "$HOME/.antrc" ]; then. "$HOME/.antrc"fi# provide default configuration valuesif [ -z "$rpm_mode" ]; thenrpm_mode=falsefiif [ -z "$usejikes" ]; thenusejikes=$use_jikes_defaultfifi# Setup Java environment in rpm modeif $rpm_mode; thenif [ -f /usr/share/java-utils/java-functions ]; then. /usr/share/java-utils/java-functionsset_jvmset_javacmdfifi# OS specific support. $var _must_ be set to either true or false.cygwin=false;darwin=false;mingw=false;case "`uname`" inCYGWIN*)cygwin=true;;Darwin*)darwin=trueif [ -z "$JAVA_HOME" ]; thenif [ -x '/usr/libexec/java_home' ]; thenJAVA_HOME=`/usr/libexec/java_home`elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; thenJAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Homefifi;;MINGW*)mingw=true;;esacif [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ]; then## resolve links - $0 may be a link to ant's homePRG="$0"progname=`basename "$0"`# need this for relative symlinkswhile [ -h "$PRG" ]; dols=`ls -ld "$PRG"`link=`expr "$ls" : '.*-> \(.*\)$'`if expr "$link" : '/.*' > /dev/null; thenPRG="$link"elsePRG=`dirname "$PRG"`"/$link"fidoneANT_HOME=`dirname "$PRG"`/..# make it fully qualifiedANT_HOME=`cd "$ANT_HOME" > /dev/null && pwd`fi# For Cygwin and Mingw, ensure paths are in UNIX format before# anything is touchedif $cygwin; then[ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --unix "$ANT_HOME"`[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`fiif $mingw; then[ -n "$ANT_HOME" ] && ANT_HOME="`(cd "$ANT_HOME"; pwd)`"[ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"fi# set ANT_LIB locationANT_LIB="${ANT_HOME}/lib"if [ -z "$JAVACMD" ]; thenif [ -n "$JAVA_HOME" ]; then# IBM's JDK on AIX uses strange locations for the executablesif [ -x "$JAVA_HOME/jre/sh/java" ]; thenJAVACMD="$JAVA_HOME/jre/sh/java"elif [ -x "$JAVA_HOME/jre/bin/java" ]; thenJAVACMD="$JAVA_HOME/jre/bin/java"elseJAVACMD="$JAVA_HOME/bin/java"fielseJAVACMD=`which java 2> /dev/null `if [ -z "$JAVACMD" ]; thenJAVACMD=javafififiif [ ! -x "$JAVACMD" ]; thenecho "Error: JAVA_HOME is not defined correctly."echo " We cannot execute $JAVACMD"exit 1fi# Build local classpath using just the launcher in non-rpm mode or# use the Jpackage helper in rpm mode with basic and default jars# specified in the ant.conf configuration. Because the launcher is# used, libraries linked in ANT_HOME/lib will also be included, but this# is discouraged as it is not java-version safe. A user should# request optional jars and their dependencies via the OPT_JAR_LIST# variableif $rpm_mode && [ -x /usr/bin/build-classpath ]; thenLOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"# If no optional jars have been specified then build the default listif [ -z "$OPT_JAR_LIST" ]; thenfor file in /etc/ant.d/*; doif [ -f "$file" ]; thencase "$file" in*~|*#*|*.rpmsave|*.rpmnew);;*)for dep in `cat "$file"`; doOPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep"done;;esacfidonefi# If the user requested to try to add some other jars to the classpathif [ -n "$OPT_JAR_LIST" ]; then_OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"if [ -n "$_OPTCLASSPATH" ]; thenLOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"fifi# Explicitly add javac path to classpath, assume JAVA_HOME set# properly in rpm modeif [ -f "$JAVA_HOME/lib/tools.jar" ]; thenLOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"fiif [ -f "$JAVA_HOME/lib/classes.zip" ]; thenLOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"fi# if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be# user CLASSPATH first and ant-found jars after.# In that case, the user CLASSPATH will override ant-found jars## if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour# with ant-found jars first and user CLASSPATH afterif [ -n "$CLASSPATH" ]; then# merge local and specified classpathif [ -z "$LOCALCLASSPATH" ]; thenLOCALCLASSPATH="$CLASSPATH"elif [ -n "$CLASSPATH_OVERRIDE" ]; thenLOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"elseLOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"fi# remove class path from launcher -cp optionCLASSPATH=""fielse# not using rpm_mode; use launcher to determine classpathsif [ -z "$LOCALCLASSPATH" ]; thenLOCALCLASSPATH=$ANT_LIB/ant-launcher.jarelseLOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATHfifiif [ -n "$JAVA_HOME" ]; then# OSX hack to make Ant work with jikesif $darwin; thenOSXHACK="${JAVA_HOME}/../Classes"if [ -d "${OSXHACK}" ]; thenfor i in "${OSXHACK}"/*.jar; doJIKESPATH="$JIKESPATH:$i"donefififi# Allow Jikes support (off by default)if $usejikes; thenANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"fi# For Cygwin, switch paths to appropriate format before running java# For PATHs convert to unix format first, then to windows format to ensure# both formats are supported. Probably this will fail on directories with ;# in the name in the path. Let's assume that paths containing ; are more# rare than windows style paths on cygwin.if $cygwin; thenif [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null; thenformat=mixedelseformat=windowsfi[ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --$format "$ANT_HOME"`ANT_LIB=`cygpath --$format "$ANT_LIB"`[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --$format "$JAVA_HOME"`LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`if [ -n "$CLASSPATH" ]; thenCP_TEMP=`cygpath --path --unix "$CLASSPATH"`CLASSPATH=`cygpath --path --$format "$CP_TEMP"`fiCYGHOME=`cygpath --$format "$HOME"`fi# Show script help if requestedif $show_help; thenecho $0 '[script options] [options] [target [target2 [target3] ..]]'echo 'Script Options:'echo ' --help, --h print this message and ant help'echo ' --noconfig suppress sourcing of /etc/ant.conf,'echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'echo ' configuration files'echo ' --usejikes enable use of jikes by default, unless'echo ' set explicitly in configuration files'echo ' --execdebug print ant exec line generated by this'echo ' launch script'echo ''fi# add a second backslash to variables terminated by a backslash under cygwinif $cygwin; thencase "$ANT_HOME" in*\\ )ANT_HOME="$ANT_HOME\\";;esaccase "$CYGHOME" in*\\ )CYGHOME="$CYGHOME\\";;esaccase "$JIKESPATH" in*\\ )JIKESPATH="$JIKESPATH\\";;esaccase "$LOCALCLASSPATH" in*\\ )LOCALCLASSPATH="$LOCALCLASSPATH\\";;esaccase "$CLASSPATH" in*\\ )CLASSPATH="$CLASSPATH\\";;esacfi# Execute ant using eval/exec to preserve spaces in paths,# java options, and ant argsant_sys_opts=if [ -n "$CYGHOME" ]; thenif [ -n "$JIKESPATH" ]; thenant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""elseant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""fielseif [ -n "$JIKESPATH" ]; thenant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""fifiant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" -Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\""if $ant_exec_debug; then# using printf to avoid echo line continuation and escape interpretation confusionprintf "%s\n" "$ant_exec_command $ant_exec_args"fieval "$ant_exec_command $ant_exec_args"