freebsd-ports/devel/apache-ant/files/ant.sh.in
Ernst de Haan f8d4392d0b Fixed 'ant' shell script. Previously the '-lib' option did not
work correctly.

Bumped PORTREVISION.
2004-01-12 13:40:00 +00:00

104 lines
2.8 KiB
Bash

#!/bin/sh
#
#-*- mode: Fundamental; tab-width: 4; -*-
# ex:ts=4
#
# FreeBSD-specific startup script for Apache Ant.
#
# See: http://ant.apache.org/
#
# $FreeBSD$
#
DEFAULT_JAVACMD=%%JAVA%%
DEFAULT_JAVA_HOME=%%JAVA_HOME%%
DEFAULT_JIKES=false
ANT_HOME=%%ANT_HOME%%
#-----------------------------------------------------------------------------
# Determine configuration settings
#-----------------------------------------------------------------------------
# Load system-wide configuration
if [ -f "%%PREFIX%%/etc/ant.conf" ]; then
. %%PREFIX%%/etc/ant.conf
fi
# Load user-specific configuration
if [ -f "${HOME}/.antrc" ]; then
. "${HOME}/.antrc"
fi
# Determine if Jikes should be used
if [ -z "${usejikes}" ]; then
usejikes=${DEFAULT_JIKES};
fi
# Set ANT_LIB location
ANT_LIB="${ANT_HOME}/lib"
# Determine 'java' executable
if [ -z "${JAVACMD}" ]; then
if [ -n "${JAVA_HOME}" ]; then
JAVACMD="${JAVA_HOME}/bin/java"
else
JAVACMD=${DEFAULT_JAVACMD}
fi
fi
# Check if 'java' executable can be found
if [ ! -x "${JAVACMD}" ]; then
echo "Error: JAVA_HOME is not defined correctly: ${JAVA_HOME}"
echo " Unable to execute ${JAVACMD}"
exit 1
fi
#-----------------------------------------------------------------------------
# Determine CLASSPATH
#-----------------------------------------------------------------------------
# Prepend LOCALCLASSPATH variable with ant-launcher.jar
if [ -z "${LOCALCLASSPATH}" ]; then
LOCALCLASSPATH=${ANT_LIB}/ant-launcher.jar
else
LOCALCLASSPATH=${ANT_LIB}/ant-launcher.jar:${LOCALCLASSPATH}
fi
# FreeBSD-specific: Add the .jar files from ${PREFIX}/share/java/classes
if [ "${ANT_INCLUDE_SHARED_JARS}" = "YES" ]; then
for JAR_FILE in "%%PREFIX%%/share/java/classes"/*.jar; do
# If the directory is empty, then the input string is returned
if [ -f "${JAR_FILE}" ]; then
if [ -z "${LOCALCLASSPATH}" ]; then
LOCALCLASSPATH="${JAR_FILE}"
else
LOCALCLASSPATH="${JAR_FILE}":"${LOCALCLASSPATH}"
fi
fi
done
fi
#-----------------------------------------------------------------------------
# Determine all Ant options
#-----------------------------------------------------------------------------
# Add Jikes flag if appropriate
if ${usejikes}; then
ANT_OPTS="${ANT_OPTS} -Dbuild.compiler=jikes"
fi
#-----------------------------------------------------------------------------
# Execute Ant
#-----------------------------------------------------------------------------
if [ -n "${JIKESPATH}" ]; then
exec "${JAVACMD}" ${ANT_OPTS} -classpath "${LOCALCLASSPATH}" -Dant.home="${ANT_HOME}" -Djikes.class.path="${JIKESPATH}" org.apache.tools.ant.launch.Launcher ${ANT_ARGS} -lib "${CLASSPATH}" "$@"
else
exec "${JAVACMD}" ${ANT_OPTS} -classpath "${LOCALCLASSPATH}" -Dant.home="${ANT_HOME}" org.apache.tools.ant.launch.Launcher ${ANT_ARGS} -lib "${CLASSPATH}" "$@"
fi