views:

31

answers:

2

I have a set of databases that are built using scripts that are run using ant. I have the scripts for each database in a separate directory.

root (build.xml) - db1 (build.xml, *.sql) - db2 (build.xml, *.sql) ...

The root build.xml has a target ...

The build.xml in each of the subfolders is essentially the same but for the database name.

Is there a way to refactor this to one single build file that runs the sql scripts in each of the folders against the corresponding databases?

TIA

A: 

Depends very much on what's in your build files. In general, <for> or <foreach> might help you to iterate over the sub-folders and apply a piece of script to each of them.

Wolfgang
+1  A: 

Have a look at the subant task. The examples in the docs show how it can be used to iteratively invoke ant builds in subdirectories.

Ash