2014-07-23 85 views
2

我想知道是否有可能在Ant(v1.9.4)中製作類似於: if((a = 1或a = 2)和(b = 3))然後......螞蟻 - 如果條件/和 - 或

我試圖

<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> 

但我得到了比錯誤,同時運行它...

感謝您的幫助,

問候,

回答

3

使用Ant-contrib,您必須在if任務下具有單個條件,如下所示(您不能同時擁有<or><and>)。您也不需要檢查屬性是否被設置爲在語義上覆蓋屬性時的值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> 
+0

完美!!謝謝 – Thiago