Browse Source

Bye-bye <do>...

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272628 13f79535-47bb-0310-9956-ffa450edef68
master
Diane Holt 23 years ago
parent
commit
a87016010e
5 changed files with 1 additions and 218 deletions
  1. +1
    -1
      WHATSNEW
  2. +0
    -64
      docs/manual/CoreTasks/do.html
  3. +0
    -1
      docs/manual/coretasklist.html
  4. +0
    -6
      docs/manual/tasksoverview.html
  5. +0
    -146
      src/main/org/apache/tools/ant/taskdefs/Do.java

+ 1
- 1
WHATSNEW View File

@@ -148,7 +148,7 @@ Other changes:

* New tasks <replaceregexp>, <checksum>, <translate>, <waitfor>,
<manifest>, <vsscp>, <vssadd>, <vsscreate>, <splash>, <basename>, <dirname>,
<concat>, <do>.
<concat>.

* A new combined <mail> task, which replaces the old <mail> and
<mimemail> tasks, has been added. The <mimemail> task, and


+ 0
- 64
docs/manual/CoreTasks/do.html View File

@@ -1,64 +0,0 @@
<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>


+ 0
- 1
docs/manual/coretasklist.html View File

@@ -38,7 +38,6 @@
<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>


+ 0
- 6
docs/manual/tasksoverview.html View File

@@ -389,12 +389,6 @@ documentation.</p>
the target files, all the target files are removed. </p></td>
</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


+ 0
- 146
src/main/org/apache/tools/ant/taskdefs/Do.java View File

@@ -1,146 +0,0 @@
/*
* 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);
}

}

Loading…
Cancel
Save