Ant terms - at first glance “if” or “if”

Question

If the ant target uses both if and if parameters, which are evaluated first?

Example

What comes first, chicken or egg ?,.

<target name="prepare" if="chicken" unless="egg" > <echo>Dinner time. Chicken is served!</echo> </target> 

Will ant evaluate chicken property first? Or the property of an egg?

+7
conditional condition ant target
source share
1 answer

This is not a matter of evaluation, since the properties are either set or not set before the target is called.

EDIT: I looked at source 1.8.1, and the logic is as follows:

 if (!testIfAllows()) { project.log(this, "Skipped because property '" + project.replaceProperties(ifCondition) + "' not set.", Project.MSG_VERBOSE); return; } if (!testUnlessAllows()) { project.log(this, "Skipped because property '" + project.replaceProperties(unlessCondition) + "' set.", Project.MSG_VERBOSE); return; } 

So unless is irrelevant if the if fails. But keep in mind that they have nothing to do with evaluating properties. He simply scans them to see if they are installed.

+9
source share

All Articles