You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Greg Roodt <gr...@gmail.com> on 2010/04/13 18:37:37 UTC

Two pass compile for instrumented code

Hi

I have an Ant build that consists of the basic compile, test, package,
report phases.
The report phase is a bit slow (Clover particularly) for developers looking
for quick feedback on tests. Developers dont need Clover reports, Checkstyle
etc etc every time and we mainly prefer these to be generated on our CI
server. This would be easy except for the requirement that for some reports
(Clover again) the compiled code needs to be instrumented.

Basically, Im looking for a 2 pass compile. The first compile is a regular
Java compile. The second is a compile with Clover instrumentation enabled.
These would need to compile to different destination directories, lets call
them bin and bin-clover.

During the compile phase, if we are generating a report, we need to compile
to both bin and bin-clover. When not generating reports, only to bin.
During the test phase, if we are generating a report, we need to run the
tests against bin-clover. When not generating reports, we need to run the
tests against bin.
The package phase will always package bin.

Still with me? Can anybody think of an elegant way to do this without
writing duplicate targets for the compile and test phases?
I've got it working, but I've got a lot of duplication and Im sure theres a
tidier way to do it.

Basically what Im after is 2 targets:
run-tests: compile, test
release: compile, test, package, report

Without duplicating too much in compile and test.

Cheers
Greg

Re: Two pass compile for instrumented code

Posted by Greg Roodt <gr...@gmail.com>.
On Tue, Apr 13, 2010 at 7:51 PM, Antoine Levy-Lambert <an...@gmx.de>wrote:

>
> -------- Original-Nachricht --------
> > Datum: Tue, 13 Apr 2010 17:37:37 +0100
> > Von: Greg Roodt <gr...@gmail.com>
> > An: Ant Users List <us...@ant.apache.org>
> > Betreff: Two pass compile for instrumented code
>
> > Hi
> >
> > I have an Ant build that consists of the basic compile, test, package,
> > report phases.
> > The report phase is a bit slow (Clover particularly) for developers
> > looking
> > for quick feedback on tests. Developers dont need Clover reports,
> > Checkstyle
> > etc etc every time and we mainly prefer these to be generated on our CI
> > server. This would be easy except for the requirement that for some
> > reports
> > (Clover again) the compiled code needs to be instrumented.
> >
> > Basically, Im looking for a 2 pass compile. The first compile is a
> regular
> > Java compile. The second is a compile with Clover instrumentation
> enabled.
> > These would need to compile to different destination directories, lets
> > call
> > them bin and bin-clover.
> >
> > During the compile phase, if we are generating a report, we need to
> > compile
> > to both bin and bin-clover.
> Do you actually need to compile to both ? Or do you compile to bin, then
> instrument the classes from bin into bin-clover ?
>

I've taken another look at the Clover Ant tasks and there are basically 2
options.
1. Compile code with Clover compiler enabled, this instruments on the fly
and then hands off to regular compiler. Currently what Im doing.
2. Instrument source code and then compile manually.
So I could instrument src to src-clover and compile src-clover to bin-clover
I guess.



>
>
> When not generating reports, only to bin.
> > During the test phase, if we are generating a report, we need to run the
> > tests against bin-clover. When not generating reports, we need to run the
> > tests against bin.
>
> I would do something like this
>
> <condition property="classes.dir.for.tests" value="bin-clover" else="bin">
>  <isset property="clover"/>
> </condition>
>
> <junit>
> ....
> <classpath>
> <pathelement location="${classes.dir.for.tests}"/>
> </classpath>
> </junit>
>


Thanks for the suggestion. Im going to see if I can wire something like this
into my script. I'll report back what I uncover.



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

Re: Two pass compile for instrumented code

Posted by Antoine Levy-Lambert <an...@gmx.de>.
-------- Original-Nachricht --------
> Datum: Tue, 13 Apr 2010 17:37:37 +0100
> Von: Greg Roodt <gr...@gmail.com>
> An: Ant Users List <us...@ant.apache.org>
> Betreff: Two pass compile for instrumented code

> Hi
> 
> I have an Ant build that consists of the basic compile, test, package,
> report phases.
> The report phase is a bit slow (Clover particularly) for developers
> looking
> for quick feedback on tests. Developers dont need Clover reports,
> Checkstyle
> etc etc every time and we mainly prefer these to be generated on our CI
> server. This would be easy except for the requirement that for some
> reports
> (Clover again) the compiled code needs to be instrumented.
> 
> Basically, Im looking for a 2 pass compile. The first compile is a regular
> Java compile. The second is a compile with Clover instrumentation enabled.
> These would need to compile to different destination directories, lets
> call
> them bin and bin-clover.
> 
> During the compile phase, if we are generating a report, we need to
> compile
> to both bin and bin-clover. 
Do you actually need to compile to both ? Or do you compile to bin, then instrument the classes from bin into bin-clover ?


When not generating reports, only to bin.
> During the test phase, if we are generating a report, we need to run the
> tests against bin-clover. When not generating reports, we need to run the
> tests against bin.

I would do something like this

<condition property="classes.dir.for.tests" value="bin-clover" else="bin">
  <isset property="clover"/>
</condition>

<junit>
....
<classpath>
<pathelement location="${classes.dir.for.tests}"/>
</classpath>
</junit>


Regards,

Antoine

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