tags:

views:

23

answers:

1

Is it possible to import a file in ant's build.xml if a property is set, if not then don't import it.

Is there a way OTHER THAN using ant-contrib if task.

Thanks

+1  A: 

Yes, you can. For example:

<target name="importFile" depends="myProperty.check" if="myPropertyIsSet">
    <echo>Import my file here</echo>
</target>

<target name="myTarget.check">
    <condition property="myPropertyIsSet">
        <and>
            <!-- Conditions to check if my property is set. -->
        </and>
    </condition>
</target>

Available conditions are described in Apache Ant Manual.

uthark
Thanks will give it a try
That did not work. As of ant 1.7 you cannot use import inside a target. It has to be a top level task
Ouch, my fault. Also, is optional attribute of import task not enough for you?
uthark