Menu

#55 Add listeners to javac ANT task and instrument transparently

some future version
open
None
6
2004-09-03
2004-08-26
acid-art
No

It would be very useful to have ability to instrument
classes transparently.

This may be done by defining new “emma” sub-task like
“setup” which will accept all necessary data like “instr”
task but it will also add listener to the Project. After that
it is possible to add listeners and handle events related to
the ends of “javac” task and instrument all files produced
by this task.

This will be useful for existing big build systems. This will
enable emma support without rewriting of big build files.
Only few lines at the beginnig of ANT build file.

In init() method of of "setup" task you may add listener
by getProject().addBuildListener(BuildListener listener). In
you build listener implementation in method
taskFinished(BuildEvent event) you may check where
task was Javac. If so you may get distdir property and
instrument all files in there. The code would be something
like that

If(event.getTask() instanceof Javac)
{
File distdir = ((Javac) event.getTask()).getDestdir();
//instrument files in distdir directory
}

Best regards and many thatnks for the exelent tool.

Artem.

Discussion

  • Vlad Roubtsov

    Vlad Roubtsov - 2004-09-03

    Logged In: YES
    user_id=1013207

    This seems like a good idea. Needs to be researched further.
    I'll mention this to Dilum as well, to see how this intersects
    with what we are doing for the Maven plugin.

     
  • Vlad Roubtsov

    Vlad Roubtsov - 2004-09-03
    • priority: 5 --> 6
    • assigned_to: nobody --> dranatunga
     

Log in to post a comment.