【问题标题】:How make an "here document" in Ant?如何在 Ant 中制作“这里的文档”?
【发布时间】:2010-11-13 01:29:28
【问题描述】:

如何将 Ant 脚本编写为:

... ...
begin of HERE DOCUMENT > ./outfile.txt
xxx
toto
yyy
zzz
end of HERE DOCUMENT
... ...

Of 谁执行创建了一个名为 ./outfile.txt 的文件,其中包含:

xxx
toto
yyy
zzz

【问题讨论】:

    标签: ant heredoc


    【解决方案1】:

    如果文件的内容是REPLACE_ME,那么运行这个任务就可以了:

    <!-- Create the file -->
    <concat destfile="outfile.txt">REPLACE_ME</concat>
    
    <!-- This property is initialized reading user input -->
    <input
      message="Please enter file content:"
      addproperty="file_content"
    />
    
    <!-- Replace the property value inside the file -->
    <replace 
      file="outfile.txt" 
      token="REPLACE_ME"
      value="${file_content}"
    />
    

    【讨论】:

      猜你喜欢
      • 2019-09-27
      • 2011-07-12
      • 2011-06-07
      • 2011-12-11
      • 2020-02-03
      • 2020-05-05
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      相关资源
      最近更新 更多