You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Grinvald, Edward" <ED...@ca.com> on 2002/06/07 17:03:56 UTC

Get directory listing and iterate over

Hi all,
    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.
 
Any help would be appreciated.
 
Thank You,
 
Edward Grinvald
Computer Associates International
Programmer, Storage Development
Edward.Grinvald@ca.com <ma...@ca.com> 
1-631-342-6000 x76350
 

Re: Get directory listing and iterate over

Posted by Jim White <ji...@pagesmiths.com>.
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

Re: Get directory listing and iterate over

Posted by Diane Holt <ho...@yahoo.com>.
--- "Grinvald, Edward" <ED...@ca.com> wrote:
>     Since i can't seem to be able to get perl to work with <script>,

Why not?

> and javascript (luckily) can't access local filesystems

Huh?

>     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.

See the Configure section on the "External Tools and Tasks" page. (Never
used it, but it sounds like what you want.)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>