ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darrell DeBoer <darr...@apache.org>
Subject Re: [Myrmidon] Overriding TargetTask for Ant1Compat.
Date Mon, 10 Jun 2002 06:34:43 GMT
On Sun, 9 Jun 2002 12:28, Peter Donald wrote:
> At 01:55 AM 6/9/2002 +1000, you wrote:
> >I've been playing around with an Ant1CompatTargetTask, which will handle
> > "if" and "unless", without having to transform the model with <if> tasks.
> > I thought this would be a cleaner solution, without having to introduce
> > hidden tasks, which might confuse the user. (and I thought it would be
> > cool to try out.)
>
> Sounds good to me.
>
> >Any ideas how I can import the Ant1Compat library before the first target
> > is loaded? (It seems like I could provide Ant1CompatProject extends
> >DefaultProject to import the Ant1Compat library when
> > Module.createWorkspace() is called - is this the right track?) Or is this
> > sort of thing just not going to be doable in any simple way?
>
> Hmmm .. not sure exactly what the best approach. I suppose the way you
> describe would be the easiest as all you would need to do is
>
> void createWorkspace(...)
> {
>    Workspace w = super.createWorkspace(...);
>    registerAnt1Tasks( w );
>    return w;
> }

This will work, I reckon; but looking at it more closely, it requires a bunch 
of nasty changes to the ProjectBuilder used, and it doesn't provide a general 
solution to the problem of providing an alternate implementation of the 
<target> task. The only simple solution I can think of is (re)introducing an 
<import> directive to DefaultProject, which is processed *before* any of the 
targets are executed.

In fact, maybe a general solution would be to have an import directive, and 
process it in a similar way to your example above:

    private Workspace createWorkspace( final ExecutionFrame frame )
    {
        final DefaultWorkspace workspace = new DefaultWorkspace();
        setupLogger( workspace );
        workspace.setFrame( frame );

	// Register tasklibs from <import> directives.
	registerImports( workspace );

        return workspace;
    }

Unfortunately, this breaks down the "everything-is-a-task" model, but it 
allows us to do some pre-processing before we turn the Project over to the 
Executor.

What do you reckon?

>
> Alternatively you could transform the target element from <target ...> to
> <ant1.target ...> and make sure this results in the ant1 version of class
> being used. Im not sure if this will work but I believe this is where Adam
> wanted to go (May even be there now?).

This is sort of what I wanted, but won't work, since <ant1.target> won't be 
available until the <import> task has been processed (and after the 
ant1compat library has been imported, the "ant1." prefix isn't needed, since 
imported tasks override core ones).

-- 
ciao,
Daz

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message