Hi,

I'm using a Java class to execute an Ant project, and am unable to direct 
compile errors to the log file used by my BuildLogger.

Here's an abbreviated version of my code:

Project p = new Project();
p.init();
p.setUserProperty("ant.file", "common.xml") //more on this later
DefaultLogger logger = new DefaultLogger();
p.addBuildListener(logger);
PrintStream ps = new PrintStream(new FileOutputStream("task.log"));
logger.setOutputPrintStream(ps);
logger.setErrorPrintStream(ps);
p.executeTarget("myTarget");

As for the common.xml file above, it does some build pre-processing tasks 
including getting the files I want to build from the source repository. Among 
those files is the "build.xml" file that contains the <javac> task. 

common.xml triggers "build.xml" using an <ant targetFile="build.xml"....../>

All works well when I run my Java class from a command prompt, unless there is 
a compile error during the <javac> task. While my Java class gets notified of 
the error via a BuildException, the compiler error messages get dumped to my 
command line window (Windows) instead of "task.log". 

I understand that the Sun Javac class (I'm using the modern compiler in Ant 
1.7) defaults to System.err, but is there any way I can force it to my output 
file?

Thanks,
Kevin





*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************

Reply via email to