ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Allan <>
Subject RE: Passing targets to subprojects with ant using javascript
Date Fri, 29 Mar 2002 01:18:32 GMT
After reading the antlist archive a little better, I found a thread from
January that matched my situation in which Peter showed a way which is much
better.  Turns out I was trying to do it backwards.  Instead of having my
subproj script be a dependency for my targets, it's much more natural to
have the targets call the script.  As Peter suggested:

<target name = "clean">
 <antcall target = "call">
  <param name = "" value = "clean"/>

Then all references in the javascript are to "call", instead of the target
I'm trying to pass.  Don't know what the heck I was thinking before!

My modified example is included below just to complete the thread - critique
is always welcome.


-- Steve

  <!-- clean target -->
  <target name = "clean">
   <antcall target = "dosubproj">
    <param name = "target" value = "clean"/>

  <!-- dosubproj target calls ant in each subproject and passes target -->
  <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(
	list snipped to save space
      for (i = 0; i < subproj.length; i++) {
         target = new"target"));
         build = testproj.createTask('ant');
         build.setDir(new"basedir") + "/"
+ subproj[i]));
         // Pass the target name unless it's the default target
         if(target != "") {
      }]]> </script></target>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message