Grinvald, Edward wrote:
> Since i can't seem to be able to get perl to work with <script>,
> and javascript (luckily) can't access local filesystems (and is
> therefore not a good substituion to perl), i am in a bit of confusion
> as to how to do the following:
> I have a larget number 20+ of subprojects that i'd need to compile/build
> /dist/etc. they are all under one src directory. Is there a way
> for me to go that directory, get the listing, and then using antcall
call
> one function that will do everything (function already written) for
> all the subdirectories/projects in that src directory, in one loop.
Both JavaScript (Rhino) and Java scripts (BeanShell) can use any Java
class (including those of Ant), and so can perform any operation
what-so-ever (it could be argued that Ant should use policy-based
security for tasks and scripts, but such is not - yet - the case).
Anyhow, Rhino is easier to use than BeanShell since the configuration is
simply drop-in the jar files, whereas BeanShell needs a line to added to
a BSF (Bean Scripting Framework) configuration file.
Also, as the Dianne and Dominique say, adding custom tasks in Java is a
simple thing.
Since this is an Ant FAQ, I've attached a sample that uses BeanShell.
It should help you get started (converting to Rhino is pretty trivial,
but this is some old code and I don't have time to test right now).
In this example, a <path> element is used to find all the "build.xml"
files in sibling directories whose names match "plugin_*" and call a
given target in each. The name of each such directory is also <echo>'ed.
jim
|