加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 如果和除非在蚂蚁

发布时间:2020-12-16 07:51:38 所属栏目:百科 来源:网络整理
导读:我想澄清ANT脚本中的if和unless语句 我有以下代码: condition property="hasExtensions" contains string="${Product_version}" substring="Extensions"/conditionexec executable="${TrueCM_App}ssremove.exe" unless="hasExtensions" .../exec 这是否意
我想澄清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,我想你会得到你想要的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读