Echo linebreak to file using Phing on Windows
Asked Answered
S

1

10

In my build script I'm trying to output the date and SVN revision number to a file in the build directory. I would like the date and revision number on separate line, but can't get a linebreak to output to the file. I've tried all sorts of methods:

    <echo file="${build.dir}\build.txt">DATE = ${DATE} \r\n \\\r\\\n PHP_EOL</echo>
    <echo msg="DATE: ${DATE} \r\n \\\r\\\n PHP_EOL 0x0D0A SVN revision: ${svn.lastrevision} . PHP_EOL" file="${build.dir}\build.txt" append="true" />

Has anyone else managed to get a linebreak through to file with Phing? I've looked at the code in phing, and it uses fwrite. I can only guess the strings in my build.xml are getting escaped in some way before being handled by fwrite?

I guess I may have to resort to using ExecTask?

Souterrain answered 9/8, 2011 at 10:50 Comment(0)
P
16

You can make use of ${line.separator}, see Built-In PropertiesDocs.

<echo msg="DATE: ${DATE}${line.separator}SVN revision: ${svn.lastrevision}${line.separator}" file="${build.dir}\build.txt" append="true" />
Phalansterian answered 9/8, 2011 at 10:56 Comment(2)
Very helpful! Can't even guessSimonize
@hakre, I tried the same in my case, where I have a here-document delimited EOF, but it is still not working. Could you please answer my question. I have an open bounty :)Marsden

© 2022 - 2024 — McMap. All rights reserved.