#!/bin/bash
#export JAVA_HOME=$(sed -ne '/JDKHome/{s/.*<JDKHome>\(.*\)<\/JDKHome>.*/\1/p;q;}' settings.xml)
export JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 | awk '/java.home/{print $NF}')
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/rt.jar
export PATH=$JAVA_HOME/bin:${PATH}
# Do not combine clean and summary targets in single ant call;
# it leads to errors every other run.
#tools/apache-ant-1.9.16/bin/ant clean summary
if [ -z "$1" ]
then
    tools/apache-ant-1.9.16/bin/ant init
	#tools/apache-ant-1.9.16/bin/ant help
elif [ "$1" == "deliver" ]
then 
	tools/apache-ant-1.9.16/bin/ant deliver
elif [ "$1" == "help" ]
then 
	tools/apache-ant-1.9.16/bin/ant help
elif [ "$1" == "clean" ]
then 
	tools/apache-ant-1.9.16/bin/ant clean
elif [ "$1" == "summary" ]
then
	tools/apache-ant-1.9.16/bin/ant clean
	tools/apache-ant-1.9.16/bin/ant summary
elif [ -z "$2" ]
then
    tools/apache-ant-1.9.16/bin/ant clean
	tools/apache-ant-1.9.16/bin/ant -DinputDirCmdLine="$1" summary
else
    tools/apache-ant-1.9.16/bin/ant clean
	tools/apache-ant-1.9.16/bin/ant -DinputDirCmdLine="$1" -DpreviousInputDirCmdLine="$2" summary
fi

