ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: conditional global variables?
Date Mon, 27 Sep 2010 00:28:17 GMT
There are several ways this can be done:

One is to use multiple tasks:

<target name="compile">
    <antcall target=""/>
    <antcall target="compile.release"/>

    <property name="build.classes" value="${build}/dev/classes"/>

<target name="compile.release"
    <property name="build.classes" value="${build}/release/classes"/>

In the example you gave, you could simply set the property "type" to
either "dev" or "release":

    <property name="build.classes" value="${build}/${type}/classes"/>

You can also use separate XML property files:

    <xmlproperty file="build.${type}.xml" keeproot="false"/>

Or, you can use the antcontrib library which includes a conditional
"if" statement. If you do this, I would put the ant-contrib.jar file
in a directory called "antlib" in the root of your project and use the
following <typedef>:

<taskdef resource="net/sf/antcontrib/antlib.xml">
        <pathelement location="${basedir}/antlib/ant-contrib.jar"/>

This way, ant will work without having to specifically install the
ant-contrib.jar file.

You can find Ant-Contrib at:

The <if> task looks like this:

    <isset property="type">
        <property name="build.classes" value="${build}/dev/classes"/>
        <property name="build.classes" value="${build}/release/classes"/>

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message