Antでログ出力3

とりあえず用。echoタスクを使う。


<target name="exec1">
<echo file="log1.txt">Hello</echo>
<echo file="log1.txt" append="true">OH!</echo>
<echo file="log1.txt" append="true">Good-bye</echo>
</target>


でも、改行が出力されないので、すべて1行に表示されてしまう。
下のようにやれば複数行で出力されるけど、美しくない。
改行コードが\nになっちゃうし。


<target name="exec2">
<echo file="log2.txt">Hello
</echo>
<echo file="log2.txt" append="true">OH!
</echo>
<echo file="log2.txt" append="true">Good-bye
</echo>
</target>


と思っていたら、line.separatorを使えばOKだった。


<target name="exec3">
<echo file="log3.txt">Hello${line.separator}</echo>
<echo file="log3.txt" append="true">OH!${line.separator}</echo>
<echo file="log3.txt" append="true">Good-bye${line.separator}</echo>
</target>


Antは、JavaのSystemプロパティも参照できるようになっているので、
それを利用しているだけ(のはず)。
マニュアル見るまで、気付かなかったなぁ。