2009-07-22 108 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}" 
/>