You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Michael D. Simpson" <ms...@itglink.com> on 2000/11/06 18:26:39 UTC

Capturing ANT Output

I want a servlet to run ANT on a form submission and display its output in HTML. I plan to just use the object org.apache.tools.ant.Main directly instead of exec'ing a new process. 

How can I capture ANT's output to get it printed to my servlet's HMTL output stream?


Re: Capturing ANT Output

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "MDS" == Michael D Simpson <ms...@itglink.com> writes:

 MDS> I want a servlet to run ANT on a form submission and display its
 MDS> output in HTML. I plan to just use the object
 MDS> org.apache.tools.ant.Main directly instead of exec'ing a new
 MDS> process.

You could even bypass Main and directly work with a Project object I
think.

 MDS> How can I capture ANT's output to get it printed to my servlet's
 MDS> HMTL output stream?

Ant's output is not really generated by the tasks, targets or whatever
but by the BuildLogger associated to it. There shouldn't be any
System.out.println-s left, everything happens in a event driven
logging system.

What you probably want to do is to attach a BuildListener to your
Project instance and build your output based on the generated
events. A BuildLogger is just a special kind of BuildListener that is
allowed to write to System.out (you don't need that).

As your target format is HTML, maybe XmlLogger is a starting point (or
maybe not, I'm not sure). There is a XSLT stylesheet in src/etc that
transforms the output of XmlLogger to (X)HTML.

Stefan

Re: Capturing ANT Output

Posted by raleigh <ss...@raleigh.ibm.com>.
Hi 
I think that there can be two ways to solve your problem 
1) If you write an Buildlistener. I use a Buildlistener and the -logfile parameter to send me the result of the build by e-mail. It should be possible to write an Buildlistener which converts the logfile to HTML. Check the FAQ there is an example how to write a buildlistener this helped me a lot
2) You can write a own logger class. I only know this from the manual, but I do not know if there is an example. Possibly Stefan Bodewig knows where you can find one.

Yours
Stefan S.