Question
如果 ant 目标同时使用if and unless,首先评估哪个?
Example
先有鸡还是先有蛋? 。 。 。
<target name="prepare" if="chicken" unless="egg" >
<echo>Dinner time. Chicken is served!</echo>
</target>
蚂蚁会先评估鸡的属性吗?还是鸡蛋属性?
这实际上不是评估问题,因为在调用目标之前属性要么已设置,要么未设置。
编辑:我查看了 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;
}
So the unless
没关系,除非if
通过。但请记住,这些与评估属性没有任何关系。它只是查找它们以查看它们是否已设置。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)