I found the answer to my problem, so I thought I'd share it to help others who may run across it. My error was assuming that the output you see from Ant coming from System.err and System.out and that just redirecting that would allow me to capture all the output. To have all of the ant output go to the same place, however, you have to create a BuildLogger and add it to the BuildListeners for your project. If you do not do this, but only redirect the System.err and System.out, you will only your the output your own classes. The best way to do this is the look at the source code to org.apache.tools.ant.Main.java and follow what is done in there. Pay special attention to the createLogger() method and use the addBuildListener() method in the Project class. I hope this explanation makes sense and that others may benefit from it.
-Craig ----- Original Message ----- From: "Craig Minton" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 20, 2002 2:55 PM Subject: Capturing the ant output when starting ant from inside a servlet I have created a servlet that will kick off Ant and record all of the output to log file. I also have created my own task that will pull my source files from PVCS Dimensions. This runs perfectly when calling Ant from a command line. For calling it from a servlet, I have essentially used the same code that was inside Main.java to reroute System.out and System.err to a logfile, create a project, and then execute the target. When I do this, however, the ONLY output I get in the log file is the output for the task that pulls the code from Dimensions. All other output seems to disappear, including the target lines, such as init:, dist:, etc. The Ant script continues to run correctly, I just do not receive any output. Again, I am calling the main build.xml file which calls the task that pulls the code from Dimensions. I am not calling that task directly. So I am very confused as to why I would only be logging the output that my home-grown task creates. Thanks to the archive of this user-list, I have been able to solve all of my other problems, but this one has me stumped. Any advice would be greatly appreciated and I will gladly answer questions if I have not provided enough information here. On a side note, I have to agree with others that parts of Ant are not documented well, or at all. Case in point, the Project class. I was able to find the information on how to use it on this mailing list archive, but it would be very nice if that was included in the documentation and the methods were documented. -Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
