ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: ant MSG_ERR does not appear to be generated
Date Tue, 30 Dec 2003 12:06:11 GMT
| Am I confusing Project.MSG_ERR with "event at error level"?
No,  I meant Project.MSG_ERR.

You need to change your build listener to handle the
priority of buildFinished event.

The reason for the change in ant 1.6.0 in the messages was that:

  <target name="compile"
        description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${dist}"/>
  </target>

Would generate MSG_ERR log events, (for the compiler messages sent on
the standard error stream) and 

  <target name="compile"
        description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${dist}" fork="yes"/>
  </target>

Would generate MSG_WARN log events for the same messages.

This was of course wrong, so ant needed to make an incompatible change
- either all standard error stream output should be at MSG_ERR level or
all at MSG_WARN level. It was felt that
it would be better to be all at MSG_WARN level.

Peter


Brian O'Halloran wrote:

>Peter -- I think I understand, however I'm still a little confused and
>unable to find a way to trap an event at error level.  Attached is some
>simple code to illustrate my example.
>
>To run, first compile Listner.java and then run as "ant -listener
>Listener", this should generate a compile error, which should in turn
>generate a Project.MSG_ERR == 0.
>
>Examine the generated file "testlistener.txt", there are no entries for
>"0".
>
>Can you please confirm my findings.  Any thoughts on how to trap an
>event at error level?
>
>Am I confusing Project.MSG_ERR with "event at error level"?
>
>Thanks,
>Brian 
>
>On Mon, 2003-12-29 at 10:19, Peter Reilly wrote:
>  
>
>>This was changed in ant 1.6.0.
>>
>>The problem was that the event priority of std error has been changed
>>from err to warning as sometimes it was output at error level and
>>sometimes it was output at warning level (when fork or exec was used).
>>
>>There should still be an event at error level:
>>ant -find compile.xml -logger org.apache.tools.ant.XmlLogger
>>
>>generates the following:
>> <build time="1 second" error="/home/preilly/learning/ant/compile.xml:3: 
>>Compile failed; see the compiler error output for details.">
>>    <task name="mkdir" 
>>location="/home/preilly/learning/ant/compile.xml:2: " time="0 
>>seconds"></task>
>>    <task name="javac" 
>>location="/home/preilly/learning/ant/compile.xml:3: " tim
>>......
>>
>>Peter
>>Brian O'Halloran wrote:
>>
>>    
>>
>>>I recently converted to ant 1.6.0 from 1.5.4.
>>>
>>>Part of our build process writes build PASS/FAIL to a postgresql db.
>>>
>>>I have implemented an ant listener that looks at logged messages and
>>>determines if any errors occur during the build;
>>>
>>>   public void messageLogged(BuildEvent event) {
>>>
>>>       // check all messages for build errors
>>>       if(event.getPriority() == Project.MSG_ERR)
>>>           buildStatus = "F";
>>>
>>>   }
>>>
>>>When I invoke ant with -listener and there are javac compile errors, I
>>>find that event.getPriority() never sees any MSG_ERR type messages.
>>>
>>>I'm mostly seeing MSG_VERBOSE and MSG_DEBUG with a much smaller number
>>>of MSG_WARN and MSG_INFO, but never any MSG_ERR.
>>>
>>>With ant 1.5.4 MSG_ERR would always be generated with a javac compile
>>>error.
>>>
>>>Anyone else seeing this behaviour with 1.6.0?  Should I be looking for
>>>errors by some other mechanism?
>>>
>>>Brian O'Halloran
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>>    
>>
>>------------------------------------------------------------------------
>>
>><project name="TestListener" default="compile" basedir=".">
>>    <description>
>>        test listener for MSG_ERR
>>    </description>
>>  <!-- set global properties for this build -->
>>  <property name="src" location="."/>
>>  <property name="dist"  location="."/>
>>
>>  <target name="compile"
>>        description="compile the source " >
>>    <!-- Compile the java code from ${src} into ${build} -->
>>    <javac srcdir="${src}" destdir="${dist}"/>
>>  </target>
>>
>></project>
>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>
>>import org.apache.tools.ant.BuildListener;
>>import org.apache.tools.ant.BuildEvent;
>>
>>import java.io.IOException;
>>import java.io.FileWriter;
>>import java.io.PrintWriter;
>>
>>/**
>> * Created by IntelliJ IDEA.
>> * User: briano
>> * Date: Dec 29, 2003
>> * Time: 6:18:36 PM
>> * To change this template use Options | File Templates.
>> */
>>public class Listener implements BuildListener{
>>
>>    PrintWriter fileOut;
>>
>>    public void buildStarted(BuildEvent event) {
>>
>>        try {
>>            fileOut = new PrintWriter( new FileWriter( "testlistener.txt" ) );
>>        } catch (IOException e) {
>>
>>        }
>>
>>    }
>>
>>    public void buildFinished(BuildEvent event) {
>>
>>        fileOut.close();
>>
>>    }
>>
>>    public void targetStarted(BuildEvent event) {
>>    }
>>
>>    public void targetFinished(BuildEvent event) {
>>    }
>>
>>    public void taskStarted(BuildEvent event) {
>>    }
>>
>>    public void taskFinished(BuildEvent event) {
>>    }
>>
>>    public void messageLogged(BuildEvent event) {
>>
>>        fileOut.println(event.getPriority());
>>
>>    }
>>
>>
>>}
>>    
>>
>>------------------------------------------------------------------------
>>
>>
>>/**
>> * Created by IntelliJ IDEA.
>> * User: briano
>> * Date: Dec 29, 2003
>> * Time: 6:29:08 PM
>> * To change this template use Options | File Templates.
>> */
>>public class TestListener {
>>
>>    foo;
>>
>>}
>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>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


Mime
View raw message