2010-05-04 90 views
0

我嘗試寫Ant任務的負荷,即做以下(僞代碼):保存和屬性

if(property1 == null) 
    gets property1 from user input and saves this value(so when next time script will be executed the value must be used) 
else 
    use value 

因此,與其他的話,如果我在第一次運行腳本,必須問一些價值並保存這個值以備將來使用 而主要的東西只能用於ANT核心任務。

回答

2

你可以嘗試這樣的事:

<target name="load-properties"> 
    <property file="test.properties" /> 
    </target> 

    <target name="ask-user" unless="my-property" > 
    <input 
     message="Please provide property" 
     addproperty="my-property" /> 
    <echo file="test.properties" message="my-property=${my-property}" /> 
    </target> 

    <!-- try to load properties-file first, ask user if property is not found --> 
    <target name="main" depends="load-properties, ask-user"> 
    <echo>${my-property}</echo> 
    </target> 
+0

它的工作原理PERFEKT,謝謝! – 2010-05-04 13:00:42