views:

311

answers:

1

I use Ant to build Delphi applications (called from CruiseControl).

I want ant to recursively search through a directory tree looking for files *.dpr and when found call either a second build.xml, or preferable a macro or target, passing each of the found file names as a 'parameter'. I have found that I can use subant to find build.xml files and run them sequentially, but this is not what I want, as I want to avoid the need to create a build.xml for each application.

What I'm trying to avoid is having to itemize my applications in my build.xml, but rather have ant find them.

Please don't tell me to use a different build tool as we already have a big investment in using Ant.

+2  A: 

If you use ant-contrib, you can use a for loop:

<for param="file">
  <fileset dir="${process.dir}" includes="**/*.dpr" />
  <sequential>
    <ant antfile="subbuild.xml">
      <property name="in" value="@{file}"/>                            
    </ant>
  </sequential>
</for>

You can also call a macro or a target using this method.

James Sulak
Thanks, I haven't looked at ant-contrib up to now. I'll have a look.
Richard A