xml – 如果和除非在蚂蚁

我想澄清ANT脚本中的if和unless语句

我有以下代码

<condition property="hasExtensions">
    <contains string="${Product_version}" substring="Extensions">
</condition>

<exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions">
    ...
</exec>

这是否意味着上述< exec>如果Product_version不包含字符串“Extensions”,则会执行ssremove.exe吗?

那么相反的情况如何:如果它包含字符串“Extensions”?我的代码看起来像这样:

<condition property="hasExtensions">
    <contains string="${Product_version}" substring="Extensions">
</condition>
<!-- here below it does not have the string "Extensions" -->
<exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions">
    ...
</exec>

<!-- below is for if it has the string "Extensions" -->
<exec executable="${TrueCM_App}\ssremove.exe" if="hasExtensions">
    ...
</exec>
你有正确的逻辑,但我不确定< exec> task接受if和unless属性.有关详细信息,请参阅 docs.

你可能需要包装< exec>检查条件的目标中的任务.例如:

<condition property="hasExtensions">
    <contains string="${Product_version}" substring="Extensions">
</condition>

<target name="ssremove" unless="hasExtensions">
    <exec executable="${TrueCM_App}\ssremove.exe">
        ...
    </exec>
</target>

然后,如果你运行ant ssremove,我想你会得到你想要的.

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念