如何在Ant中创建“here here”?

时间:2009-07-22 15:35:24

标签: ant heredoc

如何编写Ant脚本:

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

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

xxx
toto
yyy
zzz

1 个答案:

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