> 
> What about creating a "controller" build file that is responsible for
> creating the templated build files and invoking them?  That 
> is the 'hack'
> solution idea, I suppose.
> 

That way you probably would have to use system properties to tell the
controller what buildfile to create and finally what target to invoke on it.
This would make it kind of hard to use the command line interface.  Of
course I could provide my own CLI.  But also if I use the <ant> task I would
have to go through the controller and pass properties for buildfile and
target.

My goal is it to make it as easy as possible for the user to use the build
mechanisms.  Of course many users would probably object that something as
intransparent as I'm trying to do is easy...

I wrote a very simple ProjectHelper subclassing the default
ProjectHelperImpl and do something very ugly: I start by instantiating a new
Project and ProjectHelperImpl in the parse method, run that project (which
creates or updates the buildfiles) then go on and parse the target Project.
Something like:

public class MyProjectHelper extends ProjectHelperImpl {
    public void parse(Project project, Object source) throws BuildException
{
        if (!(source instanceof File)) {
            throw new BuildException("Only File source supported by my
plugin");
        }
        Project update = new Project();
        update.setCoreLoader(project.getCoreLoader());
        update.init();
        update.addBuildListener((BuildListener)
project.getBuildListeners().get(0));
        new ProjectHelperImpl().parse(update, new
File("C:\\temp\\build.xml"));
        update.executeTarget(update.getDefaultTarget());

        super.parse(project, source);
    }
}

I'll probably have to change that ;-)

--
knut

Reply via email to