SUMMARY="Java-based build tool similar to 'make'"
DESCRIPTION="Apache Ant is a Java library and command-line tool whose mission \
is to drive processes described in build files as targets and extension \
points dependent upon each other. The main known usage of Ant is the build of \
Java applications. Ant supplies a number of built-in tasks allowing to \
compile, assemble, test and run Java applications. Ant can also be used \
effectively to build non Java applications, for instance C or C++ applications.
More generally, Ant can be used to pilot any type of process which can be \
described in terms of targets and tasks.
Ant is written in Java. Users of Ant can develop their own "antlibs" \
containing Ant tasks and types, and are offered a large number of ready-made \
commercial or open-source "antlibs".
Ant is extremely flexible and does not impose coding conventions or directory \
layouts to the Java projects which adopt it as a build tool.
Software development projects looking for a solution combining build tool and \
dependency management can use Ant in combination with Apache Ivy.
The Apache Ant project is part of the Apache Software Foundation."
HOMEPAGE="http://ant.apache.org/"
COPYRIGHT="1999-2021 The Apache Software Foundation"
LICENSE="Apache v2"
REVISION="2"
SOURCE_URI="http://archive.apache.org/dist/ant/source/apache-ant-$portVersion-src.tar.bz2"
CHECKSUM_SHA256="044e2c0a66c90112d67789d267f049ae947fde384e29b1f8c14ada9bead0fe44"
SOURCE_DIR="apache-ant-$portVersion"

ARCHITECTURES="any"
GLOBAL_WRITABLE_FILES="
	settings/etc/ant.conf auto-merge
	"

PROVIDES="
	ant_core = $portVersion compat >= 1
	cmd:ant = $portVersion compat >= 1
	"
REQUIRES="
	haiku
	java:environment >= 11
	"

BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	java:environment == 11
	"

PATCH()
{
	sed -i 's/depends=\"jars,test-jar\"/depends=\"jars\"/' build.xml
}

BUILD()
{
	source /system/data/profile.d/openjdk11.sh
	export PATH=$JDK11_HOME/bin:$PATH
	export JAVA_HOME="$JDK11_HOME"
	export DISABLE_ASLR=1
	ANT_HOME= ./build.sh
}

INSTALL()
{
	source /system/data/profile.d/openjdk11.sh
	export JAVA_HOME=$JDK11_HOME
	export ANT_HOME=$libDir/ant
	./build.sh install-lite

	# symlink the executable to binDir
	mkdir -p $binDir
	ln -s $ANT_HOME/bin/ant $binDir

	mkdir -p $settingsDir/etc
	echo ANT_HOME=$ANT_HOME > $settingsDir/etc/ant.conf

	rm $ANT_HOME/bin/*{.bat,.cmd}
}
