ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Toomey, Kevin H (ATS, IT)" <>
Subject Redirecting <javac> compile errors
Date Thu, 10 Jan 2008 18:34:11 GMT

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.setUserProperty("ant.file", "common.xml") //more on this later
DefaultLogger logger = new DefaultLogger();
PrintStream ps = new PrintStream(new FileOutputStream("task.log"));

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?


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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message