Show
Ignore:
Timestamp:
05/06/08 13:35:47 (19 months ago)
Author:
jon
Message:

Fallback to ant on the system path if it cannot be found in $ANT_HOME or ANT_HOME is not set

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/ant

    r434 r1587  
    1818################################################################################ 
    1919 
    20 if [ "$ANT_HOME" == "" ] ; then 
    21   export TMPDIR="$$".tmpdir 
    22   mkdir /tmp/$TMPDIR 
    23  
    24   ANT_HOME=`(cd /tmp/$TMPDIR; ant -diagnostics | sed -n -e 's/^ant\.home: //p' | head -1)` 
    25  
    26   rmdir /tmp/$TMPDIR 
    27  
    28   echo please set ANT_HOME, guessing $ANT_HOME 
    29 else 
    30   echo ANT_HOME is $ANT_HOME 
    31 fi 
    32  
    3320# 
    3421# For NetBeans, you should not need to adjust anything to 
     
    4027# build.xml -> Run As -> Ant Build... -> Classpath -> User Entries -> Add JARs... 
    4128# 
    42 $ANT_HOME/bin/ant -noclasspath -lib third_party/junit "$@" 
     29 
     30find_ant(){ 
     31 
     32  # if $ANT_HOME is set then search for ant there 
     33  if [ "x$ANT_HOME" != "x" ]; then 
     34    if [ -x "$ANT_HOME/bin/ant" ]; then 
     35      echo $ANT_HOME/bin/ant 
     36      return 
     37    else 
     38      echo "Did not find ant in $ANT_HOME/bin" >&2 
     39    fi 
     40  else 
     41    echo "ANT_HOME is not set" >&2 
     42  fi 
     43 
     44  # Otherwise use whatever is in $PATH 
     45  result=$(which ant 2>/dev/null) 
     46  if [ -z "$result" ]; then 
     47    echo "Could not find ant. You need to install it. See http://ant.apache.org/ for details." >&2 
     48    exit 1 
     49  fi 
     50  echo $result 
     51  exit 0 
     52} 
     53 
     54ant_exec=$(find_ant) 
     55n=$? 
     56if [ $n -ne 0 ]; then 
     57        exit $n 
     58fi 
     59echo "Using $ant_exec" 
     60$ant_exec -noclasspath -lib third_party/junit "$@"