ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Abley" <james.ab...@gmail.com>
Subject Re: Redirecting <javac> compile errors
Date Tue, 15 Jan 2008 22:06:02 GMT
On 10/01/2008, Toomey, Kevin H (ATS, IT) <Kevin.Toomey@thehartford.com> wrote:
> 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
>

What happens when you run your build using the ANT command line?

Have you tried replacing System.err with a reference to your logger?

Cheers,

James

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message