If you don't know what is Ant and Ant-Contrib, please refer to the reference.
brew install ant
brew install ant-contrib
edit build.xml:
<?xml version="1.0"?>
<project name="hello" basedir=".">
<target name="hello-ant">
<echo>Hello, world!</echo>
</target>
</project>
run command below:
ant hello-ant
update build.xml:
<?xml version="1.0"?>
<project name="hello" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/local/Cellar/ant-contrib/1.0b3/share/ant/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="hello-ant">
<echo>Hello, world!</echo>
</target>
<target name="hello-ant-contrib">
<property name="test.value" value="A"/>
<if>
<equals arg1="${test.value}" arg2="A" />
<then>
<echo message="Test value you have specified is A." />
</then>
<else>
<echo message="Test value you have specified is not A." />
</else>
</if>
</target>
</project>
run command below:
ant hello-ant-contrib
To integrate Ant with Ant-Contrib, you have two choices:
Copy ant-contrib-version.jar to the lib directory of your Ant installation, or on your CLASSPATH environment variable. If you want to use one of the tasks in your project, add the line
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
to your build file.
Keep ant-contrib-version.jar in a separate location. You now have to tell Ant explicitly where to find it (say in /usr/share/java/lib):
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/java/lib/ant-contrib-version.jar"/>
</classpath>
</taskdef>