• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recursively iterate folders with Ant

 
ah bo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering if this is possible to do in Ant. I want do produce a zip file for each directory that I encounter under an umbrella directory by going through all the folders under the umbrella folder recursively. e.g.

If I have the following structure:

C:\Umbrella_Folder\ABC\file1
C:\Umbrella_Folder\ABC\file2
C:\Umbrella_Folder\DEF\file3
C:\Umbrella_Folder\DEF\file4

With the above structure, I want to produce ABC.zip (which includes file1 and file2) and DEF.zip (which includes file3 and file4). Can this be done? Thanks a lot in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably, if you use Ant+JavaScript. Ant alone isn't likely to be capable of that much programmability.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote an article on scripting Ant builds a while back. That might be of interest to you.

Having said that, I believe "the Ant way" to do something like what you're describing would be to write a custom Ant task (in Java) instead of embedding code in a scripting language.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using the ant-contrib tasks.

We don't use them on a regular basic, but a while back I seem to recall trying it out and it did what I wanted. Then I decided I didn't really need it.
 
Conor Williams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>type Mybuild.bat

for /d %%j in (C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1\*.) do c:\users\cono
r2\desktop\javane~1\neural~1\mybuild2.bat %%j

C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>type mybuild2.bat
cd %1
c:\apache-ant-1.8.2\bin\ant
cd ..

C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic