"Fossies" - the Fresh Open Source Software Archive

Member "UNICORE-Client-7.4.1/plugins/org.apache.ant_1.10.3.v20180417-1627/bin/ant" (4 May 2018, 11557 Bytes) of package /windows/misc/UNICORE_Client-7.4.1-win32.win32.x86.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/sh
    2 
    3 # Licensed to the Apache Software Foundation (ASF) under one or more
    4 # contributor license agreements.  See the NOTICE file distributed with
    5 # this work for additional information regarding copyright ownership.
    6 # The ASF licenses this file to You under the Apache License, Version 2.0
    7 # (the "License"); you may not use this file except in compliance with
    8 # the License.  You may obtain a copy of the License at
    9 #
   10 #     http://www.apache.org/licenses/LICENSE-2.0
   11 #
   12 # Unless required by applicable law or agreed to in writing, software
   13 # distributed under the License is distributed on an "AS IS" BASIS,
   14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15 # See the License for the specific language governing permissions and
   16 # limitations under the License.
   17 
   18 # Extract launch and ant arguments, (see details below).
   19 ant_exec_args=
   20 no_config=false
   21 use_jikes_default=false
   22 ant_exec_debug=false
   23 show_help=false
   24 
   25 if [ -z "$PROTECT_NL" ]; then
   26   PROTECT_NL=true
   27   os=`uname -s`
   28   rel=`uname -r`
   29   # heirloom bourne-shell used by Solaris 10 is not POSIX
   30   # it lacks features necessary to protect trailing NL from subshell trimming
   31   if [ "$os" = SunOS -a "$rel" = "5.10" ]; then
   32     PROTECT_NL=false
   33   fi
   34 fi
   35 
   36 for arg in "$@"; do
   37   if [ "$arg" = "--noconfig" ]; then
   38     no_config=true
   39   elif [ "$arg" = "--usejikes" ]; then
   40     use_jikes_default=true
   41   elif [ "$arg" = "--execdebug" ]; then
   42     ant_exec_debug=true
   43   elif [ my"$arg" = my"--h" -o my"$arg" = my"--help"  ]; then
   44     show_help=true
   45     ant_exec_args="$ant_exec_args -h"
   46   else
   47     if [  my"$arg" = my"-h" -o  my"$arg" = my"-help" ]; then
   48       show_help=true
   49     fi
   50 
   51     if [ "$PROTECT_NL" = "true" ]; then
   52       # pad the value with X to protect trailing NLs from subshell output trimming
   53       esc_arg="${arg}X"
   54     else
   55       esc_arg="${arg}"
   56     fi
   57 
   58     # wrap all arguments as "" strings, escape any internal back-slash, double-quote, $, or back-tick characters
   59     #  use printf to avoid echo interpretation behaviors such as escapes and line continuation
   60     # Mac bsd_sed does not support group-0, so pattern uses group-1
   61     # Solaris sed only processes lines with trailing newline, passing in an extra newline
   62     # subshell (heirloom and posix) will trim the added trailing newline
   63     esc_arg="`printf '%s\n' "$esc_arg" | sed -e 's@\([$\"\`\\]\)@\\\\\\1@g' `"
   64 
   65     if [ "$PROTECT_NL" = "true" ]; then
   66       # remove the padding X added above, this syntax is POSIX compatible but not heirloom-sh
   67       esc_arg="${esc_arg%X}"
   68     fi
   69     quoted_arg="\"$esc_arg\""
   70 
   71     if $ant_exec_debug; then
   72       # using printf to avoid echo line continuation and escape interpretation
   73       printf "arg       : %s\n" "$arg"
   74       printf "quoted_arg: %s\n" "$quoted_arg"
   75     fi
   76     ant_exec_args="$ant_exec_args $quoted_arg"
   77   fi
   78 done
   79 
   80 # Source/default ant configuration
   81 if $no_config; then
   82   rpm_mode=false
   83   usejikes=$use_jikes_default
   84 else
   85   # load system-wide ant configuration (ONLY if ANT_HOME has NOT been set)
   86   if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; then
   87     if [ -f "/etc/ant.conf" ]; then
   88       . /etc/ant.conf
   89     fi
   90   fi
   91 
   92   # load user ant configuration
   93   if [ -f "$HOME/.ant/ant.conf" ]; then
   94     . $HOME/.ant/ant.conf
   95   fi
   96   if [ -f "$HOME/.antrc" ]; then
   97     . "$HOME/.antrc"
   98   fi
   99 
  100   # provide default configuration values
  101   if [ -z "$rpm_mode" ]; then
  102     rpm_mode=false
  103   fi
  104   if [ -z "$usejikes" ]; then
  105     usejikes=$use_jikes_default
  106   fi
  107 fi
  108 
  109 # Setup Java environment in rpm mode
  110 if $rpm_mode; then
  111   if [ -f /usr/share/java-utils/java-functions ]; then
  112     . /usr/share/java-utils/java-functions
  113     set_jvm
  114     set_javacmd
  115   fi
  116 fi
  117 
  118 # OS specific support.  $var _must_ be set to either true or false.
  119 cygwin=false;
  120 darwin=false;
  121 mingw=false;
  122 case "`uname`" in
  123   CYGWIN*)
  124     cygwin=true
  125     ;;
  126   Darwin*)
  127     darwin=true
  128     if [ -z "$JAVA_HOME" ]; then
  129       if [ -x '/usr/libexec/java_home' ]; then
  130         JAVA_HOME=`/usr/libexec/java_home`
  131       elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
  132         JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
  133       fi
  134     fi
  135     ;;
  136   MINGW*)
  137     mingw=true
  138     ;;
  139 esac
  140 
  141 if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ]; then
  142   ## resolve links - $0 may be a link to ant's home
  143   PRG="$0"
  144   progname=`basename "$0"`
  145 
  146   # need this for relative symlinks
  147   while [ -h "$PRG" ]; do
  148     ls=`ls -ld "$PRG"`
  149     link=`expr "$ls" : '.*-> \(.*\)$'`
  150     if expr "$link" : '/.*' > /dev/null; then
  151       PRG="$link"
  152     else
  153       PRG=`dirname "$PRG"`"/$link"
  154     fi
  155   done
  156 
  157   ANT_HOME=`dirname "$PRG"`/..
  158 
  159   # make it fully qualified
  160   ANT_HOME=`cd "$ANT_HOME" > /dev/null && pwd`
  161 fi
  162 
  163 # For Cygwin and Mingw, ensure paths are in UNIX format before
  164 # anything is touched
  165 if $cygwin; then
  166   [ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --unix "$ANT_HOME"`
  167   [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  168 fi
  169 if $mingw; then
  170   [ -n "$ANT_HOME" ] && ANT_HOME="`(cd "$ANT_HOME"; pwd)`"
  171   [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
  172 fi
  173 
  174 # set ANT_LIB location
  175 ANT_LIB="${ANT_HOME}/lib"
  176 
  177 if [ -z "$JAVACMD" ]; then
  178   if [ -n "$JAVA_HOME" ]; then
  179     # IBM's JDK on AIX uses strange locations for the executables
  180     if [ -x "$JAVA_HOME/jre/sh/java" ]; then
  181       JAVACMD="$JAVA_HOME/jre/sh/java"
  182     elif [ -x "$JAVA_HOME/jre/bin/java" ]; then
  183       JAVACMD="$JAVA_HOME/jre/bin/java"
  184     else
  185       JAVACMD="$JAVA_HOME/bin/java"
  186     fi
  187   else
  188     JAVACMD=`which java 2> /dev/null `
  189     if [ -z "$JAVACMD" ]; then
  190       JAVACMD=java
  191     fi
  192   fi
  193 fi
  194 
  195 if [ ! -x "$JAVACMD" ]; then
  196   echo "Error: JAVA_HOME is not defined correctly."
  197   echo "  We cannot execute $JAVACMD"
  198   exit 1
  199 fi
  200 
  201 # Build local classpath using just the launcher in non-rpm mode or
  202 # use the Jpackage helper in rpm mode with basic and default jars
  203 # specified in the ant.conf configuration. Because the launcher is
  204 # used, libraries linked in ANT_HOME/lib will also be included, but this
  205 # is discouraged as it is not java-version safe. A user should
  206 # request optional jars and their dependencies via the OPT_JAR_LIST
  207 # variable
  208 if $rpm_mode && [ -x /usr/bin/build-classpath ]; then
  209   LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"
  210 
  211   # If no optional jars have been specified then build the default list
  212   if [ -z "$OPT_JAR_LIST" ]; then
  213     for file in /etc/ant.d/*; do
  214       if [ -f "$file" ]; then
  215         case "$file" in
  216           *~|*#*|*.rpmsave|*.rpmnew)
  217           ;;
  218           *)
  219             for dep in `cat "$file"`; do
  220               OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep"
  221             done
  222           ;;
  223         esac
  224       fi
  225     done
  226   fi
  227 
  228   # If the user requested to try to add some other jars to the classpath
  229   if [ -n "$OPT_JAR_LIST" ]; then
  230     _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
  231     if [ -n "$_OPTCLASSPATH" ]; then
  232       LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
  233     fi
  234   fi
  235 
  236   # Explicitly add javac path to classpath, assume JAVA_HOME set
  237   # properly in rpm mode
  238   if [ -f "$JAVA_HOME/lib/tools.jar" ]; then
  239     LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
  240   fi
  241   if [ -f "$JAVA_HOME/lib/classes.zip" ]; then
  242     LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
  243   fi
  244 
  245   # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be
  246   # user CLASSPATH first and ant-found jars after.
  247   # In that case, the user CLASSPATH will override ant-found jars
  248   #
  249   # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
  250   # with ant-found jars first and user CLASSPATH after
  251   if [ -n "$CLASSPATH" ]; then
  252     # merge local and specified classpath
  253     if [ -z "$LOCALCLASSPATH" ]; then
  254       LOCALCLASSPATH="$CLASSPATH"
  255     elif [ -n "$CLASSPATH_OVERRIDE" ]; then
  256       LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
  257     else
  258       LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
  259     fi
  260 
  261     # remove class path from launcher -cp option
  262     CLASSPATH=""
  263   fi
  264 else
  265   # not using rpm_mode; use launcher to determine classpaths
  266   if [ -z "$LOCALCLASSPATH" ]; then
  267     LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
  268   else
  269     LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
  270   fi
  271 fi
  272 
  273 if [ -n "$JAVA_HOME" ]; then
  274   # OSX hack to make Ant work with jikes
  275   if $darwin; then
  276     OSXHACK="${JAVA_HOME}/../Classes"
  277     if [ -d "${OSXHACK}" ]; then
  278       for i in "${OSXHACK}"/*.jar; do
  279         JIKESPATH="$JIKESPATH:$i"
  280       done
  281     fi
  282   fi
  283 fi
  284 
  285 # Allow Jikes support (off by default)
  286 if $usejikes; then
  287   ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
  288 fi
  289 
  290 # For Cygwin, switch paths to appropriate format before running java
  291 # For PATHs convert to unix format first, then to windows format to ensure
  292 # both formats are supported. Probably this will fail on directories with ;
  293 # in the name in the path. Let's assume that paths containing ; are more
  294 # rare than windows style paths on cygwin.
  295 if $cygwin; then
  296   if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null; then
  297     format=mixed
  298   else
  299     format=windows
  300   fi
  301   [ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --$format "$ANT_HOME"`
  302   ANT_LIB=`cygpath --$format "$ANT_LIB"`
  303   [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
  304   LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
  305   LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
  306   if [ -n "$CLASSPATH" ]; then
  307     CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
  308     CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
  309   fi
  310   CYGHOME=`cygpath --$format "$HOME"`
  311 fi
  312 
  313 # Show script help if requested
  314 if $show_help; then
  315   echo $0 '[script options] [options] [target [target2 [target3] ..]]'
  316   echo 'Script Options:'
  317   echo '  --help, --h            print this message and ant help'
  318   echo '  --noconfig             suppress sourcing of /etc/ant.conf,'
  319   echo '                         $HOME/.ant/ant.conf, and $HOME/.antrc'
  320   echo '                         configuration files'
  321   echo '  --usejikes             enable use of jikes by default, unless'
  322   echo '                         set explicitly in configuration files'
  323   echo '  --execdebug            print ant exec line generated by this'
  324   echo '                         launch script'
  325   echo ''
  326 fi
  327 # add a second backslash to variables terminated by a backslash under cygwin
  328 if $cygwin; then
  329   case "$ANT_HOME" in
  330     *\\ )
  331       ANT_HOME="$ANT_HOME\\"
  332     ;;
  333   esac
  334   case "$CYGHOME" in
  335     *\\ )
  336       CYGHOME="$CYGHOME\\"
  337     ;;
  338   esac
  339   case "$JIKESPATH" in
  340     *\\ )
  341       JIKESPATH="$JIKESPATH\\"
  342     ;;
  343   esac
  344   case "$LOCALCLASSPATH" in
  345     *\\ )
  346       LOCALCLASSPATH="$LOCALCLASSPATH\\"
  347     ;;
  348   esac
  349   case "$CLASSPATH" in
  350     *\\ )
  351       CLASSPATH="$CLASSPATH\\"
  352     ;;
  353   esac
  354 fi
  355 # Execute ant using eval/exec to preserve spaces in paths,
  356 # java options, and ant args
  357 ant_sys_opts=
  358 if [ -n "$CYGHOME" ]; then
  359   if [ -n "$JIKESPATH" ]; then
  360     ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""
  361   else
  362     ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""
  363   fi
  364 else
  365   if [ -n "$JIKESPATH" ]; then
  366     ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
  367   fi
  368 fi
  369 ant_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\""
  370 if $ant_exec_debug; then
  371   # using printf to avoid echo line continuation and escape interpretation confusion
  372   printf "%s\n" "$ant_exec_command $ant_exec_args"
  373 fi
  374 
  375 eval "$ant_exec_command $ant_exec_args"