You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Dick, Brian E." <Br...@FMR.com> on 2005/06/15 18:03:08 UTC

Subant - selecting projects to build

I have my project directory structured similar to the last example in
the subant doc. I have a root directory with a common build file and
module directories with a simple build file that imports the common
build file. Currently, my project consists of 50+ modules.

I deploy these modules across 10+ host machines. Each module resides on
only one host, but a host has many modules. I have a "deployhost"
property in the module build.properties file that specifies the host for
deployment. When I want to deploy a particular module to its designated
host, I simply run "ant deploy" from the module directory and the module
"knows" where to go.

I implemented project-wide targets in the root build.xml file by
following the subant example. Each project-wide target iterates through
module directories and runs the appropriate target. I can deploy all
modules to their respective hosts by running "ant deploy" from the root
directory.

Now, I want to do something a bit more complicated. I want to deploy all
modules for a particular host. I have tried several combinations of
subant, fileset and selectors but I can't get what I want. I had to
resort to the <for> task from ant-contrib. Can anyone come up a better
solution than the following?

   <target name="deploy_by_host" description="Deploy projects by host">
      <for param="module">
         <fileset dir="modules">
            <include name="**/build.properties"/>
            <contains text="deployhost=${host}"/>
         </fileset>

         <sequential>
            <property name="module.antfile"
location="@{module}/../build.xml"/>
            <ant antfile="${module.dir}" target="deploy"
inheritAll="false"/>
            <var name="module.antfile" unset="true"/>
         </sequential>
      </for>
   </target>