2010-01-05 37 views
3

我想弄清楚如何編寫一個簡單的條件在南極 將評估爲真時,當兩個x & y屬性是真實的。如果條件在南極

<project default="all"> 
    <property name="x" value="True" /> 
    <property name="y" value="True" /> 
    <target name="all"> 
     <echo message="x is True" if="${x}" /> 
     <echo message="y is True" if="${x}" /> 
     <echo message="x AND y are True" if="${x} AND ${y}" /> 
     <echo message="x AND y are True" if="${x} &amp;&amp; ${y}" /> 
    </target> 
</project> 

我想不通的X和Y Echo消息的語法 - 我想這兩個AND和「& &」而這似乎並沒有工作(我不斷收到類似的錯誤消息:字符串沒有。識別爲有效的布爾值)

回答

5

你想,如果=「$ {x和y}」,其中x和y是同一對支架的使用方法:

<project default="all"> 
    <property name="x" value="true" /> 
    <property name="y" value="true" /> 
    <target name="all"> 
     <echo message="x is True" if="${x}" /> 
     <echo message="y is True" if="${y}" /> 
     <echo message="x AND y are True" if="${x and y}" /> 

    </target> 
</project> 

希望幫助!

+0

很棒! - 謝謝! – 2010-01-07 19:01:35