2013-06-12 36 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

感谢它现在工作得非常好 –