Hi everyone,

I am trying to substitute the original build logger in my task with Ant 1.6.1. 
I have written a wrapper-class which just forwards the events to the original 
build logger, which works fine as long as I don't try to modify the build 
events. When I change a build event, however, Ant is stopping the execution 
with the message "BUILD FAILED
Listener attempted to access System.out - infinite loop terminated"

I want to exchange the original logger because I do preprocess java-files 
which are then compiled. When there is a compile error, I want to to bend the 
error messages so that they point to the original sources rather than the 
preprocessed ones. (If this is of interest for you: the project is J2ME 
Polish, http://www.j2mepolish.org)

I am missing something here? Has anyone substituted a logger successfully? 

Thanks in advance,
   Robert

The substitution is as follows [code ahead]:

                Vector buildListeners = this.project.getBuildListeners();
                BuildLogger logger = null;
                for (Iterator iter = buildListeners.iterator(); 
iter.hasNext();) {
                        BuildListener listener = (BuildListener) iter.next();
                        if (listener instanceof BuildLogger) {
                                logger = (BuildLogger) listener;
                                break;
                        }                       
                }
                if (logger != null) {
                        this.project.removeBuildListener(logger);
                        this.project.addBuildListener( new PolishLogger(logger) 
);
                } else {
                        System.err.println("Warning: unable to replace 
Ant-logger. Compile errors 
will point to the preprocessed files instead of the original sources.");
                }


The wrapper code which is causing the trouble is:

        public void messageLogged(BuildEvent event) {           
                String message = event.getMessage();
                if (message != null && message.indexOf(".java") != -1) {
                        message = "COMPILE ERROR::" + message;
                        event.setMessage(message, event.getPriority());
                }               
                this.logger.messageLogged(event);
        }

When I just call the "messageLogged"-method of the wrapped logger, everything 
works fine.

Cheers,
   Robert

-- 
Robert Virkus
Enough Software
Vor dem Steintor 218
D-28203 Bremen
Germany
www.enough.de
[EMAIL PROTECTED]

SAY NO TO SOFTWARE PATENTS:
http://www.ffii.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to