On Monday 19 July 2010 11:12:47 Nicolas Lalevée wrote:
> On Friday 16 July 2010 18:07:57 Matt Benson wrote:
> > On Jul 16, 2010, at 8:25 AM, Nicolas Lalevée wrote:
> > > Hi,
> > >
> > > I did some other experiment with the groovy frontend to ant
> > > recently. And I
> > > would like to be able to make a groovy build file import an xml
> > > build file
> > > and vice versa.
> > >
> > > As far as I can tell, in order to do this, a simple change would be
> > > needed in
> > > ImportTask. Rather than doing this in importResource:
> > >
> > > helper.parse(getProject(), importedResource);
> > >
> > > we would do something like:
> > >
> > > ProjectHelper subHelper =
> > > ProjectHelperRepository.getInstance().getProjectHelperForBuildFile(
> > >                     importedResource);
> > >
> > > // push current stacks into the sub helper
> > > subHelper.getImportStack().addAll(helper.getImportStack());
> > > subHelper.getExtensionStack().addAll(helper.getExtensionStack());
> > > getProject().addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
> > > subHelper);
> > >
> > > subHelper.parse(getProject(), importedResource);
> > >
> > > // push back the stacks from the sub helper to the main one
> > > getProject().addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
> > > helper);
> > > helper.getImportStack().clear();
> > > helper.getImportStack().addAll(subHelper.getImportStack());
> > > helper.getExtensionStack().clear();
> > > helper.getExtensionStack().addAll(subHelper.getExtensionStack());
> > >
> > >
> > > For the little tests I have done with the groovy frontend, it seems
> > > to work
> > > quite well.
> > >
> > > Actually it seems so simple that I am wondering if I might have
> > > missed some
> > > side effect. Did I ?
> >
> > I suppose it's possible you missed something, but it seems okay.  If
> > it were me, I might work out a way to make the subHelper send its
> > imports/extensions directly back to the top-level ProjectHelper
> > rather than so much clearing and replacing, but I'll admit to being
> > somewhat paranoid.
>
> I think I got paranoid too but the other way: I didn't want to change the
> API of ProjectHelper that might be implemented around the world and bring
> backward compatibility issues.
>
> Thanks for the review, I will commit that probably with some additionnal
> unit tests.

In fact I got stuck in writing unit tests because I cannot control easily 
what's in the ProjectHelperRepository. I think I will modify it so we can 
modify its content in a live system: just like for the property helpers I 
will introduce a task to install a project helper.
So I will be able to do some ant unit tests.
Unless there are some remarks or objections as always.

Nicolas


>
> Nicolas
>
> > -Matt
> >
> > > At least the unit tests showed me that I did nothing that wrong.
> > >
> > > Nicolas
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
> > > For additional commands, e-mail: dev-h...@ant.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
> > For additional commands, e-mail: dev-h...@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
> For additional commands, e-mail: dev-h...@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to