ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose Alberto Fernandez <JFernan...@viquity.com>
Subject RE: Ant templates and more templates
Date Wed, 04 Oct 2000 20:04:27 GMT
> From: Ken Wood [mailto:kwood@i2.com]
> 
> Seems to me this has the potential to add a lot
> of code to Ant. Why not think about a pre-processor
> that generates the build.xml file from the templates
> and files that use the templates?
> 

As I said before, in particular for (2) below, I do not
think it can be done preprocessing templates, because
you need to know the runtime target efore you can know
what to expand.

My position about preprocessing, is that I am all for it as long
as it happens internally to ANT. If every time I make a change to my
build file I need to run a separate tool to generate the actual file
that I will finish using with ANT, I can assure you this is not going
to work. 

If un the other hand, ANT passes the buildfile through an XSLT or CSS
processor while reading the file and uses the resulting SAX stream
for building the tasks, well that would be wonderful.

> Again, I come from the point of view that Ant
> began as a clean, simple system for compiling
> java. I fear we could load it down with so much
> extra...
> 

I am all for simplicity, but we need some simple mechanism, from the user
point of view, on how to taylor and customize their own things.

> > Jose Alberto Fernandez wrote:
> > 
> > Writing some build files for our projects here I have come across
> > several situations in which I would have liked having some sort of
> > template facilities for ANT.
> > 
> > (1) This first is for tasks. The <java> tasks that I use are quite
> > quite monotonous: Call this class with this arguments, then call it
> > again but just change the last arguments, etc, etc.
> > One way to deal with this is to define my own task that 
> extends <java>
> > and that presets all that needs to be preset. But wouldn't 
> it be nice
> > to have a way to say tell ANT to do that without a need to 
> declare and
> > maintain new classes?
> > 
> > Something like:
> > 
> > <javataskdef name="mytask" classname="XYZ" >
> >   <classpath refid="XYZpath" />
> >   <arg value="fix value" />
> > </javataskdef>
> > 
> > Now I should be able to use:
> > 
> > <mytask fork="yes" >
> >   <arg value="changing value" />
> > </mytask>
> > 
> > And this should be equivalent to doing:
> > 
> > <java classname="XYZ" fork="yes" >
> >   <classpath refid="XYZpath" />
> >   <arg value="fix value" />
> >   <arg value="changing value" />
> > </java>
> > 
> > 
> > 
> > (2) A second situation where templates are interesting is 
> when trying
> > to interconnect tasks from on build file to another using the <ant>
> > task. In this case one usially want to have access from the marter
> > build file to the suordinate build files. Usually one would
> > have <target>s like:
> > 
> > <target name="subtarget1"  depends="..." >
> >   <ant target="subtarget1" antfile="subproject.xml" />
> > </target>
> > 
> > Every time you add a task to the subproject, you need to 
> add an entry
> > point in the project. A real syncronization problem. What I 
> would like
> > is to be able to say:
> > 
> > <target template="sub*" key="subtarget" depends="..." >
> >    <ant target="${subtarget} antfile="subproject.xml" />
> > </target>
> > 
> > So with a call like:
> > 
> >     ant subtarget1 subtarget2
> > 
> > ANT will execute the above template twice, once for each 
> substitution
> > and call the respective subtarget1 and subtarget2 in subproject.xml.
> > Now notice that the template mechanism is more generic than just
> > calling subprojects. It will allow for some nice things.
> > 
> > I do not think that (2), in particular, can be solved with XSLT
> > because you only know the substitution at execution time.
> > 
> > Does this looks as something interesting to have? I think 
> the approach
> > is quite declarative in both cases, does anybody see a major problem
> > with this?
> > 
> > Jose Alberto
> > 
> > 
> > Now,
> > 
> > 
> >
> 

Mime
View raw message