You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by James Millet <mi...@us.ibm.com> on 2004/01/28 05:02:31 UTC

Searching a log file for "Error" string




Hi,
One of the tasks in my build process is an 'exec' task that invokes a C++
compiler with its output going to a file specified in the "output"
attribute of the exec task. I would like to search that output file for the
string "Error" and fail the build if it is found. I see how to use the
"fail" task with it's 'if' and 'unless' attributes for properies, so my big
problem is how to do the search for "Error" and set (or not set) a
property.
I see <linecontains>, but that seems to be in the context of copying and I
am not doing any copies.
Any suggestions?
Thanks,
Jim Millet
millet@us.ibm.com


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


Re: Searching a log file for "Error" string

Posted by Peter Reilly <pe...@corvil.com>.
The following should do the trick in a verbose fashion.

    <loadfile property="log.property" srcfile="compiler.log">
      <filterchain>
        <linecontains>
          <contains value="Error"/>
        </linecontains>
      </filterchain>
    </loadfile>

    <condition property="has.error">
      <contains string="${log.property}" substring="Error"/>
    </condition>

    <fail if="has.error">
      It had an error
    </fail>

Peter

James Millet wrote:

>
>
>Hi,
>One of the tasks in my build process is an 'exec' task that invokes a C++
>compiler with its output going to a file specified in the "output"
>attribute of the exec task. I would like to search that output file for the
>string "Error" and fail the build if it is found. I see how to use the
>"fail" task with it's 'if' and 'unless' attributes for properies, so my big
>problem is how to do the search for "Error" and set (or not set) a
>property.
>I see <linecontains>, but that seems to be in the context of copying and I
>am not doing any copies.
>Any suggestions?
>Thanks,
>Jim Millet
>millet@us.ibm.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


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