ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hol...@apache.org
Subject cvs commit: jakarta-ant WHATSNEW
Date Mon, 29 Apr 2002 22:50:16 GMT
holtdl      02/04/29 15:50:16

  Modified:    docs/manual coretasklist.html tasksoverview.html
               .        WHATSNEW
  Added:       docs/manual/CoreTasks do.html
               src/main/org/apache/tools/ant/taskdefs Do.java
  Log:
  Even though the enthusiasm (even to just vote) was a bit, ahem,
  underwhelming, at least there weren't any overwhelming objections,
  so...
  
  Add the <do> task.
  
  Revision  Changes    Path
  1.42      +1 -0      jakarta-ant/docs/manual/coretasklist.html
  
  Index: coretasklist.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/coretasklist.html,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- coretasklist.html	22 Apr 2002 00:05:09 -0000	1.41
  +++ coretasklist.html	29 Apr 2002 22:50:16 -0000	1.42
  @@ -38,6 +38,7 @@
   <a href="CoreTasks/deltree.html"><i>Deltree</i></a><br>
   <a href="CoreTasks/dependset.html">Dependset</a><br>
   <a href="CoreTasks/dirname.html">Dirname</a><br>
  +<a href="CoreTasks/do.html">Do</a><br>
   <a href="CoreTasks/ear.html">Ear</a><br>
   <a href="CoreTasks/echo.html">Echo</a><br>
   <a href="CoreTasks/exec.html">Exec</a><br>
  
  
  
  1.13      +6 -0      jakarta-ant/docs/manual/tasksoverview.html
  
  Index: tasksoverview.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/tasksoverview.html,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- tasksoverview.html	23 Apr 2002 14:58:47 -0000	1.12
  +++ tasksoverview.html	29 Apr 2002 22:50:16 -0000	1.13
  @@ -390,6 +390,12 @@
     </tr>
   
     <tr valign="top">
  +    <td nowrap><a href="CoreTasks/do.html">Do</a></td>
  +    <td><p>Runs another target within the same buildfile, without
  +     re-running any common dependent target(s).</p></td>
  +  </tr>
  +
  +  <tr valign="top">
       <td nowrap><a href="CoreTasks/exec.html">Exec</a></td>
       <td><p>Executes a system command. When the <code>os</code>
attribute
        is specified, the command is only executed when Ant is run on one of
  
  
  
  1.1                  jakarta-ant/docs/manual/CoreTasks/do.html
  
  Index: do.html
  ===================================================================
  <html>
  
  <head>
  <meta http-equiv="Content-Language" content="en-us">
  <title>Do Task</title>
  </head>
  
  <body>
  
  <h2><a name="echo">Do</a></h2>
  <h3>Description</h3>
  <p>
  This task is similar to the
  <a href="antcall.html"><code>&lt;antcall&gt;</code></a>
  task; however, <code>&lt;do&gt;</code> will not
  re-run common dependencies. Using
  <code>&lt;antcall&gt;</code> to run several targets that all have
  the same dependency(s) will cause the dependent
  target(s) for each called target to be run again.
  This results in common targets, such as &quot;init&quot;-type targets,
  being run many times.  Using <code>&lt;do&gt;</code>
  instead of <code>&lt;antcall&gt;</code> prevents any common dependencies
  from being run more than once.
  </p>
  <p>
  <strong>Note:</strong> The <code>&lt;do&gt;</code> task
will still re-run
  any dependent target that was run prior to the <code>&lt;do&gt;</code>
task(s)
  being run.
  
  <h3>Parameters</h3>
  <table border="1" cellpadding="2" cellspacing="0">
    <tr>
      <td valign="top"><b>Attribute</b></td>
      <td valign="top"><b>Description</b></td>
      <td align="center" valign="top"><b>Required</b></td>
    </tr>
    <tr>
      <td valign="top">target</td>
      <td valign="top">The target to run.</td>
      <td valign="top" align="center">Yes</td>
    </tr>
  </table>
  
  <h3>Examples</h3>
  
  <pre>
    &lt;target name=&quot;all&quot;&gt;
      &lt;do target=&quot;target1&quot;/&gt;
      &lt;do target=&quot;target2&quot;/&gt;
    &lt;/target&gt;
  </pre>
  
  will run the targets <code>target1</code> and <code>target2</code>.
  If both <code>target1</code> and <code>target2</code> depend on,
  for example, the <code>init</code> target, it will only be run once
  rather than once for <code>target1</code> and again for <code>target2</code>.
  
  <hr>
  <p align="center">Copyright &copy; 2002 Apache Software Foundation.
  All rights Reserved.</p>
  
  </body>
  </html>
  
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Do.java
  
  Index: Do.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Target;
  import org.apache.tools.ant.Task;
  import java.util.Enumeration;
  import java.util.Hashtable;
  
  /*
   * This task is similar to the <antcall> task; however, <do> will not
   * re-evaluate all the dependencies of the specified target. Using <antcall>
   * to run several targets that all have the same dependency(s), for each
   * called target, the dependent target(s) will be run again. This results
   * in common targets, such as "init"-type targets, being run many times.
   * Using <do> instead of <antcall> prevents any common dependencies from
   * being run more than once. 
   *
   * Note: The <do> task will still re-run any dependent target that was run
   * prior to the <do> task(s) being run. 
   *
   * Usage:
   *
   * <target name="all">
   *   <do target="target1"/>
   *   <do target="target2"/>
   * </target>
   *
   *
   * @author Mark McMillan
   * @author Diane Holt <a href="mailto:holtdl@apache.org">holtdl@apache.org</a>
   *   (Clean-up for submission.)
   *
   * @since 1.5
   *
   * @ant.task category="control"
   *
   */
  
  public class Do extends Task {
  
      private String targetName;
  
      private static Hashtable hasRunList = new Hashtable();
  
      public Do() {
      }
  
      public void setTarget(String targetName) {
          this.targetName = targetName;
      }
  
      public void execute() throws BuildException {
          // Get the target property
          if (targetName == null) {
              throw new BuildException("Missing 'target' attribute.", location);
          }
  
          // This will cause all dependencies to be re-evaluated:
          //     project.executeTarget(targetName);
          // so we don't want it.
          runTarget(targetName);
      }
  
      private void runTarget(String targetName) throws BuildException {
          Target t = (Target)project.getTargets().get(targetName);
          if (t == null) {
              throw new BuildException("Target '" + targetName + "' not found.",
                  location);
          }
  
          // Run all dependencies that have not yet been run before running
          // the requested target.
          Enumeration enum = t.getDependencies();
          while (enum.hasMoreElements()) {
              String depName = (String)enum.nextElement();
              // This target has never been run
              if (hasRunList.get(depName) == null) {
                  // Recursive call to run the dependent target
                  runTarget(depName);
              }
          }
  
          // Now run the requested target
          log("Calling target '" + targetName + "'", Project.MSG_VERBOSE);
          t.performTasks();
  
          // Add to list of targets that have been run
          hasRunList.put(targetName, t);
      }
  
  }
  
  
  
  1.261     +1 -1      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.260
  retrieving revision 1.261
  diff -u -r1.260 -r1.261
  --- WHATSNEW	26 Apr 2002 16:06:51 -0000	1.260
  +++ WHATSNEW	29 Apr 2002 22:50:16 -0000	1.261
  @@ -148,7 +148,7 @@
   
   * New tasks <replaceregexp>, <checksum>, <translate>, <waitfor>,

     <manifest>, <vsscp>, <vssadd>, <vsscreate>, <splash>, <basename>,
<dirname>,
  -  <concat>.
  +  <concat>, <do>.
   
   * A new combined <mail> task, which replaces the old <mail> and
     <mimemail> tasks, has been added.  The <mimemail> task, and 
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message