ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juergen Hermann">
Subject Re: NullPointerException when adding listener
Date Thu, 21 Jul 2005 20:57:05 GMT
On Thu, 21 Jul 2005 11:42:15 -0700 (PDT), Matt Benson wrote:

>Looks like your XmlLogger object needs -some-
>configuration between instantiation and addition as a

Well, in some twisted way, yes. The XmlLogger does two things: recording 
seen tasks in "tasks", and recording timing info. When created inside the 
build script, some info is missing ('cause of missed events), leading to the 
RuntimeError and a NullPointerExeption. Which is why this thing works:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="logger.test" default="test" basedir=".">
        Test Adding Logger via Scripting

    <property name="XmlLogger.file" location="ant.log.xml"/>
    <script language="jython"><![CDATA[if 1:
        from import BuildEvent, XmlLogger

        class TardyXmlLogger(XmlLogger):
            """ Deals with errors due to missed events when we're created
                inside the build script.
            def __init__(self):
                # ignore one event, namely our own finishing
                self.ignore = True
                # add timing info for build start event
            def taskFinished(self, event):
                if not self.ignore:
                    XmlLogger.taskFinished(self, event)
                self.ignore = False

        listener = TardyXmlLogger()

    <target name="empty">

    <target name="test">
        <echo message="Hello world!"/>
        <antcall target="empty"/>

Ciao, J├╝rgen

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message