2013-06-12 37 views
0

我有一個需求,在build.xml文件中我有兩個變量。在ant build.xml中檢查參數值

雖然從Java調用程序的build.xml文件,我將通過值屬性 雖然調用命令行相同的build.xml文件,應該要求用戶輸入現在我有

檢查一個特定的屬性是否有任何值,如果沒有,那麼請求用戶輸入值

你能幫我寫這個build.xml文件嗎?

在此先感謝。

回答

3

你可以這樣說:

<target name="printMyProperty" depends="askUser"> 
    <echo message="${my.property}"/> 
</target> 

<target name="askUser" unless="my.property"> 
    <input 
      message="Enter the value for my.property:" 
      addproperty="my.property" 
      /> 
</target> 

unless屬性是解決你的問題。這意味着「只有在未設置my.property時才執行此目標」。

+0

感謝它現在工作得非常好 –