The property is set to false, but the target is still completed.

Here is 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 set to false , so how does the compress-assets target execute every time? Note the if property on the target.

+4
source share
2 answers

if does not check the value of the property, it checks if the property is set.


In the documentation:

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

[...] if the module-A-present property is set (any value, for example false ), the target will be launched.

+6
source

In Ant 1.8, if now checks that the value is true ( unless checks to be false), so you can do:

 <target name="blah" if="${do-blah}"> . . . </target> 
+5
source

Source: https://habr.com/ru/post/1308119/


All Articles