New ant tasks from ant-contrib library

4 min read >

New ant tasks from ant-contrib library

Embedded & Engineering Insights

The new collection of ant tasks from comes with some useful and interesting tasks, that one will find handy when making a build file:

Among those tasks the following ones helped me a lot :


<var name=”osfamily” value=”win”/>
use it as a property:
<echo message=”${osfamily}”/>

another cool feature is overriding properties through parameter unset=”true”
having property x:
<property name=”x” value=”aaa”>
you can overwrite it with:
<var name=”x” value”bbb” unset=”true”>
and use it as a normal property:
<echo message=”new value of x is ${x}”>


Can detect various os, possible values include “unix”, “dos”, “mac”, “os/2”, “os/400”, “z/os”, “tandem” and “windows”.
<osfamily property=””/>
<echo message=”os: ${}”/>
<equals arg1=”${}” arg2=”windows”/ >


AntCallBack is identical to the standard ‘antcall’ task, except that it allows properties set in the called target to be available in the calling target.

<target name=”init-db”depends=”init”>
<var name=”databaseURL” value=”url_1″/>
<var name=”databaseDriver” value=”driver_1″/>

<target name=”install” depends=”init”>
<antcallback target=”init-db” return=”databaseURL” />
<echo message=”foreign prop: databaseURL = ${databaseURL}”/>

you can use ${databaseURL} as if it was defined locally. This combined with the task gives you complete control of
variable throughout your script.


Have you ever wished to do something like ${${prop_name}_postfix}, you can do it now like this

<property name="database_type" value="mssql"/>
<property name="mssql_databaseDialect" value="net.sf.hibernate.dialect.SQLServerDialect"/>
<propertycopy name="databaseDialect" from="${database_type}_databaseDialect" />
<echo message="databaseDialect: ${databaseDialect}" />


It is an extension of the “exec” task, and as such, supports the same attributes.

<shellscript shell="sh" dir=".">
chmod +x ${deploy.dir}


<shellscript shell="sh" dir="."> arg1

Other cool features like:

Logic Tasks( if, for,foreach, outoutdate, runTarget, switch etc),

Network Tasks (HTTP Post, AntServer / RemoteAnt)

Performance Monitoring and Tasks( Performance Monitor, Stopwatch )
Platform Tasks (Osfamily, Shellscript)

Property Tasks (Math, Propertycopy, SortList, URLEncode, Variable )
Process Tasks (Forget, Limit )
Other Tasks (antclipse, IniFile, VerifyDesign )

can be explored at

Another special task is CC Task – Compile and link task.

cc Task – can compile various source languages and produce executables, shared libraries (aka DLLs), and static libraries. Compiler adaptors are currently available for several C/C++ compilers, FORTRAN, MIDL, and Windows Resource files.
for more info check

Unlock innovation and digital transformation for your business.

Get in touch

We are always happy to talk





165 Splaiul Unirii, Timpuri Noi Square,
TN Office 2 building, 4th floor,
District 3, Bucharest, Romania, 030134