Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 蚂蚁条件-哪一个先出现';如果';或';除非';_Ant_Conditional_Target_Conditional Statements - Fatal编程技术网

Ant 蚂蚁条件-哪一个先出现';如果';或';除非';

Ant 蚂蚁条件-哪一个先出现';如果';或';除非';,ant,conditional,target,conditional-statements,Ant,Conditional,Target,Conditional Statements,问题 如果ant目标同时使用If和除非,那么首先计算哪个 示例 先来的是什么,鸡还是蛋 <target name="prepare" if="chicken" unless="egg" > <echo>Dinner time. Chicken is served!</echo> </target> 晚餐时间。鸡肉上菜了! 蚂蚁会首先评估鸡的属性吗?还是egg属性?这实际上不是一个评估问题,因为在调用目标之前,属性要么已经设置好,要么没

问题

如果ant目标同时使用If和除非,那么首先计算哪个

示例

先来的是什么,鸡还是蛋

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

晚餐时间。鸡肉上菜了!

蚂蚁会首先评估鸡的属性吗?还是egg属性?

这实际上不是一个评估问题,因为在调用目标之前,属性要么已经设置好,要么没有设置好

编辑:我查看了1.8.1源代码,逻辑如下:

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;
}
因此,除非
if
通过,否则
除非
不会起作用。但请记住,这些与评估属性无关。它只是查看它们是否已设置。

相关的类是