Bug 30083 - Adding -logger XmlLogger cause Exception on build finished
Summary: Adding -logger XmlLogger cause Exception on build finished
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: Other other
: P2 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Jared Burns CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-23 08:11 EST by Gunnar Wagenknecht CLA
Modified: 2003-01-27 14:17 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2003-01-23 08:11:52 EST
Hi!

>If I start the script using "-logger org.apache.tools.ant.XmlLogger" the
>following output is generated. It seems the logger is working but I'm
>wondering about the exception. It seems that the Eclipse AntRunner is
>invoking something when the build is finished ?!?

I found the bug!!!!

The problem is InternalAntRunner around line 564. In the current code (build 
20030115) the build is finished and then a message is loged. But if you finish 
a build, the XmlLogger throws away some vars (buildElement). I don't know Ant 
but I think this is the root element.

------------
fireBuildFinished(getCurrentProject(), error);
if (error == null && scriptExecuted) {
  logMessage(getCurrentProject(), getTimeString(System.currentTimeMillis() - 
startTime), Project.MSG_INFO);
}
------------


A possible solution might be to fire the "build finished" event after doing the 
last log entry!!!


------------
if (error == null && scriptExecuted) {
  logMessage(getCurrentProject(), getTimeString(System.currentTimeMillis() - 
startTime), Project.MSG_INFO);
}
fireBuildFinished(getCurrentProject(), error);
------------

Cu, Gunnar
Comment 1 Darin Swanson CLA 2003-01-23 08:26:05 EST
I love bug reports where the reporter has taken the time to look closely at 
the problem...thanks!
Comment 2 Gunnar Wagenknecht CLA 2003-01-23 10:29:45 EST
Darin, there are more problems. I tried running the patched version but the 
generated XML log is always empty. I think it is not filled correctly.

Any ideas?

I'd like to help because we really need the ant build output as XML.
Comment 3 Darin Swanson CLA 2003-01-23 11:34:50 EST
The internal ant runner is closing the err and out streams too soon. 

In the finally block of run(List) you need to move the fireBuildFinished after 
the closing of err and out.  The XmlLogger doesn't write anything to disk until 
build finished.
Comment 4 Gunnar Wagenknecht CLA 2003-01-23 11:39:12 EST
Thanks. Do you think it will be fixed in next builds?
Comment 5 Darin Swanson CLA 2003-01-23 11:48:32 EST
It is already fixed in HEAD...so yes. Thanks for your help.
If you need it before then you should be able to pull from CVS the two jars 
that changed and put them into your install plugin directory (make a backup of 
the old ones first :-) ) org.eclipse.ant.core\lib (antsupportlib.jar) and 
org.eclipse.ui.externaltools\lib (antrunner.jar). It should work (worth a try 
anyways).
Comment 6 Darin Swanson CLA 2003-01-23 11:52:16 EST
Changes to InternalAntRunner to close the streams for the user specified log 
streams after build finished.

moved the "time" messaging into AntProcessBuildLogger where it belonged. 
Otherwise other loggers, such as the XmlLogger would be reporting the time 
twice.

Change the AntProcessBuildLogger to lazily retrieved the ant process. It was 
relying on a build started message before it would log any other messages. This 
was incorrect.

Reworked dealing with -projecthelp to make it more like the commandline ant 
(just for fun)
Comment 7 Darin Swanson CLA 2003-01-23 11:52:57 EST
Please verify (Jared and / or Gunnar if you are so inclined :-) )
Comment 8 Jared Burns CLA 2003-01-27 14:10:33 EST
Verified code. Gunnar, please let us know whether or not your test case is
working for you in the next build.
Comment 9 Gunnar Wagenknecht CLA 2003-01-27 14:17:44 EST
My testcase works ok now using the latest libs (antsupportlib.jar and 
antrunner.jar) from CVS HEAD.