ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: changing the main initialization procedure
Date Fri, 24 May 2002 08:20:29 GMT
OK, I've so far only implemented parts, as I'm not quite sure of how I'm
going to use it.  What it does right now is to copy all distinct top-level
nodes (including their children and attributes) from both the template and
the customization into the "target" buildfile.  All <target> nodes from the
template are overwritten by <override-target> nodes with the same value for
the "name" attribute.  (I intentionally introduced <override-target> as I
think that's something that's missing in some OOPL's, but it would be easy
to change to <target>.)  Additionally, if a <override-target> node in the
customization has a <super/> node, then that is replaced by the contents of
the template's respective <target> node.  I haven't implemented merging for
any other structures (such as <property> or <path>) but it shouldn't be
hard.

To run the template I'm using Ejen (http://ejen.sourceforge.net/), but
<style> should work fine, too.

The stylesheet takes the template buildfile as input, reads the
customization buildfile from the supplied parameter "custom-file" (which is
the path to the file), and produces the merged buildfile as output.

When I get time I'll try to do the merging with a ProjectHelper instead as
that's probably faster and more flexible.  The XSLT is kind of obscure...
Let me know if you make some interesting additions.  The stylesheet is
included as an attachment.

--
knut

P.S. Is it normal that it takes several hours for my posts to get into the
mailing list?


> -----Original Message-----
> From: Dominique Devienne [mailto:DDevienne@lgc.com]
> Sent: Freitag, 24. Mai 2002 00:28
> To: 'Ant Users List'
> Subject: RE: changing the main initialization procedure
> 
> 
> Yes, by all means, send it to me personally or through 
> ant-user at your
> convenience ;-) And thanks for offering!
> 
> I am very much interested by your approach. I know I need a templating
> system for the builds of the projects I'm trying to integrate 
> / homogenize,
> but just don't know how to go about it or which tool to use 
> yet. So far I've
> identified several possible routes: completely ad-hoc (to the point of
> writing actual Jaxp code to manipulate all these xml files!), 
> 'traditional'
> xslt like myrmidon, maybe Maven or AntHill too, or your 
> approach. From the
> little I know about each approach, yours sounds the more 
> interesting to me
> at this point (and one I could actually wrap my head around too).
> 
> Thanks, --DD
> 
> -----Original Message-----
> From: Wannheden, Knut [mailto:knut.wannheden@paranor.ch] 
> Sent: Thursday, May 23, 2002 10:40 AM
> To: 'Ant Users List'
> Subject: RE: changing the main initialization procedure
> 
> Well it's maybe abusing the true purpose of XSLT, but it's 
> what I'm doing
> anyways.  I use my buildfile template as the input for the 
> stylesheet, use
> the document() function to load the customization buildfile and do the
> merging with XSLT templates.  Of course the merging has to be 
> done by hand,
> i.e. checking if the customization buildfile overrides any
> targets/properties in the template buildfile.  So in the end 
> the stylesheet
> just copies parts from either buildfile and doesn't contain 
> the template
> itself.  I can send it to you if you wish, but it's not ready yet...
> 
> I guess if I'd write my own Ant ProjectHelper the process 
> could be a little
> bit easier, as the ProjectHelper could merge the buildfiles 
> itself by using
> the methods provided by Project.  But I still have to look 
> into that code
> first.  The XSLT approach was more straight forward for me, 
> as I already had
> something similar.
> 
> --
> knut
> 
> > -----Original Message-----
> > From: Dominique Devienne [mailto:DDevienne@lgc.com]
> > Sent: Donnerstag, 23. Mai 2002 17:29
> > To: 'Ant Users List'
> > Subject: RE: changing the main initialization procedure
> > 
> > 
> > A little off-topic, but could you point me to some info on 
> > how you can merge
> > two xml files to produce a third using an xslt stylesheet?
> > 
> > In either Myrmidon's templating system using xslt, or 'Java 
> > and XSLT' book,
> > the xslt stylesheet *contains* the xml template as well. If 
> I remember
> > correctly, you pointed out a while ago that it didn't 
> > separate the the ANT
> > build template and the stylesheet, which I agree with. It 
> > also requires to
> > know xslt to update the template, which is bad.
> > 
> > Please forgive my ignorance of XSLT related matter ;-) --DD
> > 
> > -----Original Message-----
> > From: Wannheden, Knut [mailto:knut.wannheden@paranor.ch] 
> > Sent: Thursday, May 23, 2002 3:04 AM
> > To: 'Ant Users List'
> > Subject: RE: changing the main initialization procedure
> > 
> > > 
> > > Peter Donald (have to use full name because this list is 
> > > soooo full ;) , any
> > > hint on how to include a basic templating mechanism with 
> > current Ant?
> > > I recall you favor templating, and I'm sure you can help us 
> > > (I'm interested
> > > too) and give us some advice.
> > > 
> > 
> > Just to briefly describe how I've implemented my templates: I have a
> > template buildfile (regular Ant buildfile) with some common 
> > (or default)
> > targets, paths, properties, etc.  Then for every "real" 
> > project I merge
> > (with XSLT) this template with another customization (also an 
> > Ant buildfile)
> > which overrides definitions in the template.  This works 
> like a simple
> > inheritance mechanism.  So I could have a template like:
> > 
> > <project name="template" default="compile">
> > 
> >  <property name="source-dir" value="src"/>
> >  <property name="build-dir" value="build"/>
> > 
> >  <target name="init"/>
> >  <target name="compile" depends="init">
> >   <javac srcdir="${source-dir}" destdir="${build-dir}"/>
> >  </target>
> > 
> > </project>
> > 
> > and a customization for a project (notice the additional 
> > <super/> in target
> > compile):
> > 
> > <project name="custom">
> > 
> >  <property name="build-dir" value="classes"/>
> > 
> >  <target name="idlj">
> >   <exec/>
> >  </target>
> > 
> >  <target name="compile" depends="init,idlj">
> >   <super/>
> >  </target>
> > 
> > </project>
> > 
> > which would be merged into:
> > 
> > <project name="custom" default="compile">
> > 
> >  <property name="source-dir" value="src"/>
> >  <property name="build-dir" value="classes"/>
> > 
> >  <target name="init"/>
> > 
> >  <target name="idlj">
> >   <exec/>
> >  </target>
> > 
> >  <target name="compile" depends="init,idlj">
> >   <javac srcdir="${source-dir}" destdir="${build-dir}"/>
> >  </target>
> > 
> > </project>
> > 
> > I found this to work quite nicely.  I added the <super> 
> > target because I
> > wanted as few changes as possible in the template to cause 
> > manual changes to
> > be made to the customization.
> > 
> > --
> > knut
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <mailto:ant-user-help@jakarta.apache.org>
> > 
> 
> --
> To unsubscribe, e-mail:   
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message