Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property set to false, but target still executed

Tags:

ant

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.

like image 337
Ree Avatar asked Apr 27 '10 08:04

Ree


1 Answers

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.

like image 196
Peter Lang Avatar answered Sep 28 '22 16:09

Peter Lang