2012-05-04 100 views
0

我想制作一个Ant脚本来提升SA的某些值,并将它们添加到文件中。如果运行以下脚本,属性名称将被添加到文件中而不是值?Ant将提示值插入文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<project default="run-count" name="run"> 
    <!--this file was created by Eclipse Runnable JAR Export Wizard--> 
    <!--Ant 1.7 is required  
           --> 
    <target name="run-count"> 
     <input 
      message="Please enter db-username:" 
      addproperty="db.user" 
      /> 
    </target> 

    <concat destfile="input.txt" append="true">"${db.user}"</concat> 

    <echo file="file.txt" append="true"> 
    <![CDATA[ 
     <h1>"${db.user}"</h1> 
    ]]> 
    </echo> 
</project> 

回答

1

问题是您输出到设置属性的目标范围之外的文件。

首先执行任何目标以外的内容。

所以这意味着在提示用户输入用户名之前文件输出已经完成。

解决方案...

  • concatechorun-count目标内,或
  • 包括它们依赖于run-count其他一些目标,或
  • 移动他们之前的input元素,在任何目标之外。