Hi, Ok, I tried this script and it bombed big time on my box (the jpackage one worked). I started auditing it to find what's wrong and ended up tweaking most of it. So here is the result.
Most of the logic is the same, with a bit more anal checks, some formating changes to make it more readable, "" around paths to try to catch dirs with spaces in names and a sane clathpath builder (i.e. first jvm jars, then core ant jars, then local classpath). It works for me. I'd like everyone interested to test if it works in their setups. Note that I didn't even try to integrate all the nice addons Guillaume put in the jpackage script, just to correct the jakarta rpm. I left this work for others (hint hint) Regards, -- Nicolas Mailhot
#! /bin/sh
# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
# reserved.
# load system-wide ant configuration
[ -r "/etc/ant.conf" ] && . "/etc/ant.conf"
# load user ant configuration
[ -r "$HOME/.antrc" ] && . "$HOME/.antrc"
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
case "$(uname)" in
CYGWIN*) cygwin=true ;;
Darwin*) darwin=true ;;
esac
[ -z "$ANT_HOME" -a "$rpmmode" = "true" ] && ANT_HOME="/usr"
if [ -z "$ANT_HOME" ] ; then
# try to find ANT
[ -d "/opt/ant" ] && ANT_HOME="/opt/ant"
[ -d "$HOME}/opt/ant" ] && ANT_HOME="$HOME/opt/ant"
## resolve links - $0 may be a link to ant's home
PRG=$0
progname=$(basename $0)
saveddir="$(pwd)"
# need this for relative symlinks
cd "$(dirname $PRG)"
while [ -h "$PRG" ] ; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
else
PRG="$(dirname $PRG)/$link"
fi
done
ANT_HOME="$(dirname '$PRG')/.."
# make it fully qualified
ANT_HOME=$(cd "$ANT_HOME" && pwd)
cd "$saveddir"
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if [ "$cygwin" = "true" ] ; then
[ -n "$ANT_HOME" ] && ANT_HOME=$(cygpath --unix "$ANT_HOME")
[ -n "$JAVA_HOME" ] && JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] && CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# IF your JDK uses strange locations for the executables
# (like IBM's JDK on AIX) you should set
# JAVACMD in ant's confiburation files
if [ -z "$JAVACMD" ] ; then
[ -n "$JAVA_HOME" ] && JAVACMD="$JAVA_HOME/bin/java" || JAVACMD=java
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly."
echo " We cannot execute $JAVACMD"
exit 1
fi
unset LOCALCLASSPATH ;
if [ -n "$JAVA_HOME" ] ; then
[ -f "$JAVA_HOME/lib/tools.jar" ] && LOCALCLASSPATH="$JAVA_HOME/lib/tools.jar"
[ -f "$JAVA_HOME/lib/classes.zip" ] && LOCALCLASSPATH="$JAVA_HOME/lib/classes.zip"
else
echo "Warning: JAVA_HOME environment variable is not set."
echo " If build fails because sun.* classes could not be found"
echo " you will need to set the JAVA_HOME environment variable"
echo " to the installation directory of java."
fi
if [ "$darwin" = "true" -a "$usejikes" = "true" ] ; then
OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
JARS=$(find "$OSXHACK" -name *.jar 2>/dev/null)
for jar in $JARS ; do
[ -z "$JIKESPATH" ] && JIKESPATH="$jar" ||\
JIKESPATH="$JIKESPATH":"$jar"
done
fi
if [ "$rpmmode" = "true" ] ; then
JAVALIBDIR="/usr/share/java"
JARS="ant ant-optional jaxp_parser xml_apis"
for jar in $JARS ; do
[ -z "$LOCALCLASSPATH" ] && LOCALCLASSPATH="$JAVALIBDIR/$jar.jar" ||\
LOCALCLASSPATH="$LOCALCLASSPATH":"$JAVALIBDIR/$jar.jar"
done
else
JARS=$(find "$ANT_HOME/lib" -name *.jar 2>/dev/null)
for jar in $JARS ; do
[ -z "$LOCALCLASSPATH" ] && LOCALCLASSPATH="$jar" ||\
LOCALCLASSPATH="$jar":"$LOCALCLASSPATH"
done
fi
if [ -n "$CLASSPATH" ] ; then
LOCALCLASSPATH="$LOCALCLASSPATH":"$CLASSPATH"
fi
# supply JIKESPATH to Ant as jikes.class.path
if [ -n "$JIKESPATH" ] ; then
[ "$cygwin" = "true" ] && JIKESPATH=$(cygpath --path --windows "$JIKESPATH")
ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
fi
# Allow Jikes support (off by default)
[ "$usejikes" = "true" ] && ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
# For Cygwin, switch paths to Windows format before running java
if [ "$cygwin" = "true" ]; then
ANT_HOME=$(cygpath --path --windows "$ANT_HOME")
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
LOCALCLASSPATH=$(cygpath --path --windows "$LOCALCLASSPATH")
fi
"$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="$ANT_HOME" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
# Where your java installation lives # JAVA_HOME=/usr/java/jdk #JAVA_HOME="/opt/IBMJava2-13" # You can pass some parameters to java # here if you wish to #JAVACMD="$JAVA_HOME/bin/java -Xms256m -Xmx256m" # Should we use Jikes ? #usejikes=false # Use RPM layout rpmmode=true
signature.asc
Description: PGP signature
