You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Henri Yandell <fl...@gmail.com> on 2005/02/14 03:38:32 UTC

[site] Odd Ant question

Before I lug myself off to the Ant lists, thought I'd ask here.

I'm trying to come up with a way to make the cgi work for the
downloads pages. One way would be to rewrite the cgi, have it take
arguments and be more dynamic. Another easier way would be to simply
copy the cgi file lots of times (as it's already been copied many
times already).

To do this copying, I basically want to do the equivalent of:

-------
For each downloads_*.html file
  copy downloads.cgi downloads_*.cgi
--------

Any idea how I do that in Ant? Mappers seem like they'd want to be
copying the html file to the cgi file; ie) wildcard in to and from.
There's no for loop, so not sure how I'd do such a thing.

Maybe one way would be to call a target on each file in a list of files.

Any ideas?

Hen

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org


Re: [site] Odd Ant question

Posted by Martin Cooper <mf...@gmail.com>.
I haven't tried it, but how about this:

* Use <subant> with 'genericantfile' (referencing the same build file)
and a <dirset> for the directories you want.

* In the target invoked by <subant>, use <available> to determine
whether or not the HTML file exists, and invoke another target that
only runs 'if' the property is set. That second target would do the
copy.

* Use <pathconvert> to generate the name of the CGI file based on the
name of the HTML file.

--
Martin Cooper


On Sun, 13 Feb 2005 21:38:32 -0500, Henri Yandell <fl...@gmail.com> wrote:
> Before I lug myself off to the Ant lists, thought I'd ask here.
> 
> I'm trying to come up with a way to make the cgi work for the
> downloads pages. One way would be to rewrite the cgi, have it take
> arguments and be more dynamic. Another easier way would be to simply
> copy the cgi file lots of times (as it's already been copied many
> times already).
> 
> To do this copying, I basically want to do the equivalent of:
> 
> -------
> For each downloads_*.html file
>   copy downloads.cgi downloads_*.cgi
> --------
> 
> Any idea how I do that in Ant? Mappers seem like they'd want to be
> copying the html file to the cgi file; ie) wildcard in to and from.
> There's no for loop, so not sure how I'd do such a thing.
> 
> Maybe one way would be to call a target on each file in a list of files.
> 
> Any ideas?
> 
> Hen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org


Re: [site] Odd Ant question

Posted by Henri Yandell <fl...@gmail.com>.
Thanks for the suggestions. They all sounded painful or involved more
dependencies :(

For the moment I've gone with a glorious hack:

1) Use the Xalan redirect extension to output the cgi. I'm already
using this extension so am not worried about new dependencies.
2) Use the Ant replace tag to remove the <?xml...> and newlines from
the top of the created file.

Ugly I know :)

Hen

On Mon, 14 Feb 2005 09:20:31 +0100, Stefan Bodewig <bo...@apache.org> wrote:
> On Sun, 13 Feb 2005, Henri Yandell <fl...@gmail.com> wrote:
> 
> > To do this copying, I basically want to do the equivalent of:
> >
> > -------
> > For each downloads_*.html file
> >   copy downloads.cgi downloads_*.cgi
> > --------
> >
> > Any idea how I do that in Ant?
> 
> The first answer which many people in Ant land won't like is, use
> AntContrib's[1] <for> or <foreach> task.
> 
> > Mappers seem like they'd want to be copying the html file to the cgi
> > file; ie) wildcard in to and from.
> 
> You can do better than that.
> 
> The first thing you want is having copy to copy to multiple target
> files, to do this you need Ant 1.6 and set the enablemultipolemappings
> attribute to true.
> 
> To create the mappings, the best solution is writing a custom mapper,
> this sounds more difficult than it actually is, in particular if you
> are willing to use Ant 1.6.2 where you can simply <typedef> a new
> mapper.
> 
> The basic idea is that you write a class that implements
> FileNameMapper, has a dir attribute (read a public setDir(File)
> method), completely ignores the from and to attributes and scans the
> given directory for downlod_*.html files on the first invocation of
> mapFileName.  mapFileName then returns null for any argument that's
> not download.cgi and an array consisting of all download_*.cgi files
> you need for download.cgi.
> 
> Let me know if you want to go that route and my description turns out
> to be too sketchy.
> 
> Cheers
> 
>         Stefan
> 
> Footnotes:
> [1]  http://ant-contrib.sf.net/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org


Re: [site] Odd Ant question

Posted by Stefan Bodewig <bo...@apache.org>.
On Sun, 13 Feb 2005, Henri Yandell <fl...@gmail.com> wrote:

> To do this copying, I basically want to do the equivalent of:
> 
> -------
> For each downloads_*.html file
>   copy downloads.cgi downloads_*.cgi
> --------
> 
> Any idea how I do that in Ant?

The first answer which many people in Ant land won't like is, use
AntContrib's[1] <for> or <foreach> task.

> Mappers seem like they'd want to be copying the html file to the cgi
> file; ie) wildcard in to and from.

You can do better than that.

The first thing you want is having copy to copy to multiple target
files, to do this you need Ant 1.6 and set the enablemultipolemappings
attribute to true.

To create the mappings, the best solution is writing a custom mapper,
this sounds more difficult than it actually is, in particular if you
are willing to use Ant 1.6.2 where you can simply <typedef> a new
mapper.

The basic idea is that you write a class that implements
FileNameMapper, has a dir attribute (read a public setDir(File)
method), completely ignores the from and to attributes and scans the
given directory for downlod_*.html files on the first invocation of
mapFileName.  mapFileName then returns null for any argument that's
not download.cgi and an array consisting of all download_*.cgi files
you need for download.cgi.

Let me know if you want to go that route and my description turns out
to be too sketchy.

Cheers

        Stefan

Footnotes: 
[1]  http://ant-contrib.sf.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org