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 targ开发者_运维技巧et.
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.
In Ant 1.8, if
now does check that the value is true (unless
checks for false), so you can do:
<target name="blah" if="${do-blah}">
.
.
.
</target>
精彩评论