tags:

views:

12

answers:

1

Here's a simple Ant build file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Project" default="build" basedir=".">
    <property name="compressAssets" value="false"/>

    <target name="build" depends="compress-assets"/>
    <target name="compress-assets" if="compressAssets">
        <echo message="executed"/>
    </target>
</project>

compressAssets is set to false, so how come the compress-assets target is executed every time? Note the if property on the target.

+2  A: 

if does not check for the value of the property, it checks if the property has been set.


From the documentation:

<target name="build-module-A" if="module-A-present"/>

[...] if the module-A-present property is set (to any value, e.g. false), the target will be run.

Peter Lang
OK, thank you. Must have missed that.
Ree