I originally had this:
<echo file="${my.file}"
message="This is line #1"/>
<echo file="${my.file}"
append="true"
message="This is line #2"/>
<echo file="${my.file}"
append="true"
message="This is line #3"/>
And got this in my file:
This is line#1This is line #2This is line#3
So, I tried:
<echo file="${my.file}">
This is line #1
This is line #2
This is line #3
</echo>
And got:
This is line#1This is line #2This is line#3
I did this:
<echo file="${my.file}">
This is line #1${line.separator}
This is line #2${line.separator}
This is line #3${line.separator}
</echo>
And got:
This is line#1This is line #2This is line#3
I did this:
<echo file="${my.file}">
This is line #1
This is line #2
This is line #3
</echo>
And got:
This is line#1This is line #2This is line#3
I even tried this:
<concat destfile="${my.file}">
This is line #1
This is line #2
This is line #3
</concat>
And still got:
This is line#1This is line #2This is line#3
If I do any of these to the console, it prints on separate lines. Saving them to a file, and the lines don't show up.
I'm on Win7, Ant 1.8 something.
Any ideas?
Windows Thing?
I've tried each of these on my Mac. The first one gave me the same results. However, the second way gave me three lines in the file. The third way with the ${line.separator}
added skipped every other line. The fourth way using &10;
gave me every other line with a ^M
at the end (after all, the Mac is Unix and doesn't use the CRLF ending, but just LF).
And, using <concat>
also created separate lines.
More information
I've traced down the issue to the following snippet from my build.xml
file:
This works as advertised. That is, white space and NL
show up in the resulting file:
<target name="package"
depends="-resolve,compile"
description="Packaging of the artifact">
<!-- Build version.txt and let the user figure out how to use it -->
<mkdir dir="${target.dir}"/>
<echo file="${version.file}">
Jenkins Project: ${env.JOB_NAME}
Jenkins Build Number: ${env.BUILD_NUMBER}
Build Date: ${build.date}
</echo>
<!--
<antcall target="jar"/>
<antcall target="war"/>
<antcall target="ear"/>
-->
</target>
This doesn't:
<target name="package"
depends="-resolve,compile"
description="Packaging of the artifact">
<!-- Build version.txt and let the user figure out how to use it -->
<mkdir dir="${target.dir}"/>
<echo file="${version.file}">
Jenkins Project: ${env.JOB_NAME}
Jenkins Build Number: ${env.BUILD_NUMBER}
Build Date: ${build.date}
</echo>
<antcall target="jar"/>
<antcall target="war"/>
<antcall target="ear"/>
</target>
The only difference between these snippets in the fact that I do three <antcall>
tasks AFTER I write the file. The three antcall tasks all have an if
clause, so they may or may not run based upon the properties that are set. This is a build template for our development teams, so I really would like to get this to work.
Why could the <antcall>
's be causing problems. By the way, sometimes it is so broken, I need to reopen a new console window in order to get the NL
stuff to work.
I've ran into a similar issue before, and it was a Windows codepage issue.