【问题标题】:Ant - If condition / and-orAnt - 如果条件/和-或
【发布时间】:2014-07-23 12:42:03
【问题描述】:

我想知道是否可以在 Ant (v1.9.4) 中制作类似的东西: if((a=1 or a=2) and (b=3)) then ...

我试过了

<ac:if>
        <or>
            <equals arg1="${aa}" arg2=""/>
            <not>
                <isset property="a"/>
            </not>
        </or>
        <and>
            <contains string="${b}" substring="${c}" casesensitive="false"/>
        </and>
        <then>
            <property name="b" value="true" />
        </then>
</ac:if>

但我在运行时遇到了错误......

感谢您的帮助,

问候,

【问题讨论】:

    标签: ant ant-contrib


    【解决方案1】:

    使用Ant-contrib,您必须在if 任务下有一个条件,如下所示(您不能同时拥有&lt;or&gt;&lt;and&gt;)。您也不需要检查该属性是否已设置,因为在将属性与带有equals 的值进行比较时,它已被语义覆盖:

    <if>
        <and>
            <or>
                <equals arg1="${a}" arg2="1" />
                <equals arg1="${a}" arg2="2" />
            </or>
            <equals arg1="${b}" arg2="3" />
        </and>
        <then>
            <!-- do stuff -->
        </then>
        <else>
            <!-- do other stuff -->
        </else>
    </if>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-08
      • 2019-06-18
      • 1970-01-01
      • 2013-01-15
      • 2011-05-29
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多