ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Harvey <>
Subject Any use for an optional template copy task?
Date Thu, 17 Nov 2005 23:46:37 GMT
I wrote a Task recently that alters files as they are copied to
different directories. I used it to create a website and it serves we
quite well - I imagine it would be useful for other applications where
more complex copying operations are required.
It basically works like this:
        <taskdef name="tcopy" classname="TemplateCopy" classpath="."/>
        <tcopy templatefile="${tfile}" outdir="${outdir}" srcdir="${srcdir}">
          <include name="**/*.tmpl"/>
        <tcopy templatefile="${jsfile}" outdir="${outdir}"
srcdir="${srcdir}" ext=".js">
          <include name="rolling.tmjs"/>

What it is saying is, for every file in the include list, make a token
replacement copy of the file "templatefile" to "outdir" with the
appropriate extension. So if srcdir contained 10 *.tmpl files, then 10
files (with the default *.html extension) will end up in the outdir
location, where the values in the *.tmpl files are inserted into the
base "templatefile".

In other words, I have one templatefile that contains generic
information plus some tokens:
   <h1>Some general info</h1>

and then some others - let's say "welcome.tmpl" - that contain only
token, value pairs:

  Welcome page
    <p>Welcome to my page</p>

Then the resulting page would be "welcome.html" in the outdir directory.

Is there any interest in including this with optional tasks?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message