I'm converting one of our java build systems from gnu make to ant.  I need
my top-level build.xml file to pass the targets that are requested to all of
the subprojects.  I was able to do that using javascript, but I think it
could be better, so I was hoping for some suggestions.  In particular, I
found I had to do an addTask() for each target in the build.xml.  I was
hoping there was some way to generalize that.  Here's a distilled version of
what I have:

  <!-- dosubproj target calls ant in each subproject -->
  <target name="dosubproj">
   <script language="javascript"> 
    <![CDATA[
      // Add new subprojects to this array.  They'll be built
      // in the order they appear in the array.
      var subproj = new Array(
             "jms",
             "sniiop",
             "shared", // remainder snipped
         );
      for (i = 0; i < subproj.length; i++) {
         target = new java.io.File(testproj.getProperty("target"));
         build = testproj.createTask('ant');
         build.setAntfile("build.xml");
         build.setDir(new java.io.File(testproj.getProperty("basedir") + "/"
+ subproj[i]));
         build.setInheritAll(false);
         // Pass the target name unless it's the default target
         if(target != "") {
            build.setTarget(target);
         }

         //  Is there a better way to do this?
         clean.addTask(build);
         install.addTask(build);
         main.addTask(build);
      }
     ]]> </script>
   </target>

Since I have the target name (I had to do a bit of a kludge for that, but
that's another post), it'd be nice if I could somehow use that to replace
the repetitive addTask() calls with something like

   target.addTask(build). 

Can that be done?  Or is there a better all-around approach to what I'm
trying to do?

Thanks.

-- Steve

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

Reply via email to