ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Problem in extending class
Date Tue, 08 Aug 2006 04:15:46 GMT
On Mon, 7 Aug 2006, Ben <> wrote:

> I hope this is the right place for me to ask development quesiton
> about Ant.

It is.  This is the list where development of Ant itself is discussed
and what you want might require a change to Ant, so you meet the right
people here.

> Now I'm trying to create my own "java" task and "junit" task to
> utilize this class loader.

We are talking about the non-forked execution of tha java and junit
tasks only, right?

> One problem I'm facing here is, I cannot seem to be able to extend
> class to do what I want to do.

Many if not most tasks haven't been written with extension in mind,
I'm not surprised that you don't find a clean extension point.

> The executeJava() has quite long logic that I want to re-use. But I
> can't seem to find an extension point to make use of my class
> loader.

[I'm talking about Ant's svn trunk version since we'd only make
changes there anyway]

Since we are only talking about the non-forked version, you'd probably
rather override run(CommandlineJava) - which is private - or somehow
make the task use a subclass of ExcecuteJava of yours.  ExecuteJava
creates an AntClassLoader internally, so you probably need to modify
it yourself.

I see options of making run() protected or factor out the line

             ExecuteJava exe = new ExecuteJava();

into a protected method that you could override.  I'd prefer the
second version.

> There's similar problem with the JUnitTask class. But seems there's
> a spot that I can hack in my logic. (to override the
> getCommandline() method)

Please check whether it still works with Ant's current svn trunk
version since Ant 1.7.0 using that code is coming around pretty soon.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message