Richard A
Richard A

Reputation: 2833

Ant build that finds applications and iterates across them

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.

Upvotes: 2

Views: 731

Answers (1)

James Sulak
James Sulak

Reputation: 32447

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.

Upvotes: 3

Related Questions