2009-07-22 109 views
0

如何为写一个Ant脚本:如何在Ant中创建“here文档”?

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

为之执行创建一个名为./outfile.txt为谁文件包含:

xxx 
toto 
yyy 
zzz 

回答

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}" 
/>