You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by subir bhaumik <su...@yahoo.co.in> on 2006/11/24 06:30:12 UTC
Recorder
Hi
I am not getting reply on ant user forum that's why i am posting here.
I am using ant API programmatically for build rather than writing build.xml.
It's o.k. Now i want the compilation record in a log file.I can get it by
writing the following in build.xml.
<target name="compile" depends="init"
description="compile the source " >
<record name="record-log.txt" action="start"/>
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
<record name="record-log.txt" action="stop"/>
</target>
What i get in the output file "record-log.txt" i want that file to be
generated not using build.xml but using ant API programmatically.
For that I have tried Recorder class.
The code snippet
======================================================================================
Recorder rec = new Recorder();
rec.setName("D:/subir/Downloads/example1/log.txt");
Recorder.ActionChoices reacch = new Recorder.ActionChoices();
reacch.setValue("start");
rec.setProject(p);
rec.execute();
reacch.setValue("stop");
========================================================================================
The log file looks like :
======================================================================================
compile:
[javac] Compiling 16 source files to C:\bishwakarma\builttemp\classes
BUILD FAILED
Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:938)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:758)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at buildadmin.Build.doGet(Build.java:413)
at buildadmin.Build.doPost(Build.java:543)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
=================================================================
But i want log like :
============================================================================
compile:
[javac] Compiling 4 source files to D:\subir\Downloads\example1\build
[javac] D:\subir\Downloads\example1\src\Adder.java:16: ';' expected
[javac] }
[javac] ^
[javac] 1 error
BUILD FAILED
========================================================================
Can any one give sample code or any suggestion for that?
Thanx in advance.
Warm Regards
Subir
---------------------------------
Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW
Re: Recorder
Posted by Conor MacNeill <co...@apache.org>.
Steve Loughran wrote:
> subir bhaumik wrote:
>> compile:
>> [javac] Compiling 4 source files to D:\subir\Downloads\example1\build
>> [javac] D:\subir\Downloads\example1\src\Adder.java:16: ';' expected
>> [javac] }
>> [javac] ^
>> [javac] 1 error
>
> That output comes from javac, which uses stdout or stderror for its
> outoput. I dont know how that gets merged with the recorder stuff
>
The DemuxOuptutStream setup by Ant in its Main class redirects any
output generated by classes launched by Ant, including javac, into the
Ant log system, where it is available for the Recorder tasks.
In fact, if you are running Ant programatically, you could just attach
your own listener and pick the output you want. You'll still need to add
a DemuxOutputStream or similar to get the output into the Ant log
system. Doing so, however, takes over all of your output to System.out.
Whether it is appropriate in your environment, I can't say.
Conor
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Recorder
Posted by Steve Loughran <st...@apache.org>.
subir bhaumik wrote:
> Hi
> I am not getting reply on ant user forum that's why i am posting here.
>
> I am using ant API programmatically for build rather than writing build.xml.
> It's o.k. Now i want the compilation record in a log file.I can get it by
> writing the following in build.xml.
>
> <target name="compile" depends="init"
> description="compile the source " >
> <record name="record-log.txt" action="start"/>
>
> <!-- Compile the java code from ${src} into ${build} -->
> <javac srcdir="${src}" destdir="${build}"/>
>
>
>
> <record name="record-log.txt" action="stop"/>
> </target>
>
> What i get in the output file "record-log.txt" i want that file to be
> generated not using build.xml but using ant API programmatically.
>
> For that I have tried Recorder class.
>
> The code snippet
> ======================================================================================
> Recorder rec = new Recorder();
>
> rec.setName("D:/subir/Downloads/example1/log.txt");
> Recorder.ActionChoices reacch = new Recorder.ActionChoices();
> reacch.setValue("start");
> rec.setProject(p);
> rec.execute();
> reacch.setValue("stop");
> ========================================================================================
> The log file looks like :
> ======================================================================================
> compile:
> [javac] Compiling 16 source files to C:\bishwakarma\builttemp\classes
>
> BUILD FAILED
>
> Compile failed; see the compiler error output for details.
> at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:938)
> at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:758)
> at org.apache.tools.ant.Task.perform(Task.java:364)
> at org.apache.tools.ant.Target.execute(Target.java:341)
> at org.apache.tools.ant.Target.performTasks(Target.java:369)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
> at buildadmin.Build.doGet(Build.java:413)
> at buildadmin.Build.doPost(Build.java:543)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> =================================================================
> But i want log like :
> ============================================================================
> compile:
> [javac] Compiling 4 source files to D:\subir\Downloads\example1\build
> [javac] D:\subir\Downloads\example1\src\Adder.java:16: ';' expected
> [javac] }
> [javac] ^
> [javac] 1 error
That output comes from javac, which uses stdout or stderror for its
outoput. I dont know how that gets merged with the recorder stuff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org