On Feb 10, 2005, at 11:41 AM, Matt Benson wrote:

Looks like your main question is how to accumulate,
then iterate, over these modules.

Pretty much, except for two things:

1) Stylistically, I'd prefer to that the iteration be implicit rather than explicit, i.e. a declarative style...

2) I'd like to have individual targets for the modules that I can run from the top level, e.g. "ant modules:module:foo".

If I had those targets and could also somehow create

<target name="modules:build-all" depends="modules:module:foo, modules:module:bar, modules:module:baz" />

...which is really what I had in mind for (1).

But if I gotta use explicit iteration then so be it, see below...

  It looks as though
ant-contrib has some helpful tasks.  You could set a
new property for each of your modules:  module.foo=foo
or whatever.  Then it appears you could use
ant-contrib's propertyselector task with a select
attribute value of "$${\0}" (you might have to
experiment).  This should get you a single property
containing the property-expansion notation of all
matching properties.  You can then use this list as
input to ant-contrib's for task, calling your macro
for each module name.

OK, well I finally got the chance to open up this ant-contrib box... :-) and here's what I came up with:


In build.xml:


<!-- Modules -->

  <import file="modules.ant"/>
        
  <property name="modules:module:foo" value="foo" />
  <property name="modules:module:bar" value="bar" />

  <target name="modules" depends="modules:build-all"/>

...then, in modules.ant:

        
  <project name="modules">

         <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

          <target name="modules.build-module">
                <echo message=":::::::::: building module: ${name} ::::::::::" 
/>
                <mkdir dir="webapp/modules" />
                <exec dir="webapp/modules" executable="ln">
                        <arg line="-sfh ${basedir}/modules/${name}/mount ${name}" 
/>
                </exec>
                <ant dir="modules/${name}" />
        </target>

         <propertyselector property="modules:modules"
                match="modules:module:(.*)"
                select="\1"
          />

        <target name="modules:build-all">
                <foreach
                                list="${modules:modules}"
                                target="modules.build-module"
                        param="name"
                   />
        </target>

  </project>

I still need to add the Subversion stuff, then this will be 95% of what I want, and the other 5% I can live without... :-)

Thanks for the suggestion!
—ml—


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to