时间:2010-05-04 12:28:03

标签: ant

我尝试编写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 CORE TASKS。

1 个答案:

答案 0 :(得分: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>