ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Virkus <>
Subject Integrating own BuildLogger
Date Wed, 01 Sep 2004 21:53:45 GMT
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 

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

Thanks in advance,

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);
			if (listener instanceof BuildLogger) {
				logger = (BuildLogger) listener;
		if (logger != null) {
			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());

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


Robert Virkus
Enough Software
Vor dem Steintor 218
D-28203 Bremen


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

View raw message