ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: new line in echo
Date Mon, 29 Apr 2002 19:43:42 GMT
Run the ANT build file included at the end on a Win2K machine, and open each
output log file in Notepad, and you'll see that only log2.txt has correct
line terminations for windows. As I said, I think this is a bug of ANT 1.4.1
on Windows, or someone has to explain to me why this is not a bug...

There should be a better way to output multi-line info to a file than:

  <echo file="${log2}" append="yes"
        message="line 1${nl}" />
  <echo file="${log2}" append="yes"
        message="line 2${nl}" />

And it should be either of the following:

  <echo file="${log2}" append="yes"
        message="line 1" />
  <echo file="${log2}" append="yes"
        message="line 2" />

  <echo file="${log2}" append="yes">
line 1
line 2
  </echo>

with option to target a specific OS other than the one used for the build,
to have the correct line termination on MacOS/*nix/Win32, and also an option
to strip the very beginning and end of Text section to avoid having to
write:

  <echo file="${log2}" append="yes">line 1
line 2</echo>

when one doesn't want the extra line terminations.

I'm sure someone will point out I should use <copy> with a filter instead,
but there's an <echo> task that also serves some purpose, and should be made
to work according to people expectations.

Regards, --DD


<?xml version="1.0"?>

<!-- ANT build file to test a specific feature or bug of ANT.
     Dominique Devienne <ddevienne@lgc.com>       April 2002
  -->
<project name="echo-newline" default="test" basedir=".">

  <target name="init">

    <property name="nl"
              value="${line.separator}" />
    <property name="outdir"
              location="${ant.project.name}" />
    <property name="log1"
              value="${outdir}/log1.txt" />
    <property name="log2"
              value="${outdir}/log2.txt" />
    <property name="log3"
              value="${outdir}/log3.txt" />
    <property name="log4"
              value="${outdir}/log4.txt" />
    <property name="log5"
              value="${outdir}/log5.txt" />
    <property name="log6"
              value="${outdir}/log6.txt" />

  <mkdir dir="${outdir}" />

  </target>

  <target name="test"
          depends="init">

  <echo message="Output ${log1}" />
  <echo file="${log1}" append="yes"
        message="line 1" />
  <echo file="${log1}" append="yes"
        message="line 2" />

  <echo message="Output ${log2}" />
  <echo file="${log2}" append="yes"
        message="line 1${nl}" />
  <echo file="${log2}" append="yes"
        message="line 2${nl}" />

  <echo message="Output ${log3}" />
  <echo file="${log3}" append="yes"
        message="line 1&#10;" />
  <echo file="${log3}" append="yes"
        message="line 2&#10;" />

  <echo message="Output ${log4}" />
  <echo file="${log4}" append="yes">
line 1
line 2
  </echo>

  <echo message="Output ${log5}" />
  <echo file="${log5}" append="yes">
line 1${nl}
line 2${nl}
  </echo>

  <echo message="Output ${log6}" />
  <echo file="${log6}" append="yes">
line 1&#10;
line 2&#10;
  </echo>

  </target>

</project>

-----Original Message-----
From: John Keyes [mailto:jbjk@mac.com] 
Sent: Monday, April 29, 2002 12:21 PM
To: Ant Users List
Subject: Re: new line in echo

Try:

<echo file="${logdir}/${logfile}" append="true">WmlDeviceAdapter
Failed&#10;</echo>

-John K

> <echo file="${logdir}/${logfile}" append="true">WmlDeviceAdapter Failed
> </echo>
> 
> thanks for the reply,
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message