Browse Source

Make <waitfor> set a property instead of throwing an exception if the

maximum time to wait has been exceeded.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270127 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
b251a9a8f5
2 changed files with 21 additions and 1 deletions
  1. +9
    -0
      docs/manual/CoreTasks/waitfor.html
  2. +12
    -1
      src/main/org/apache/tools/ant/taskdefs/WaitFor.java

+ 9
- 0
docs/manual/CoreTasks/waitfor.html View File

@@ -16,6 +16,9 @@
if multiple conditions are specified, then the task will wait until all conditions are true..</p>
<p></p>
<p>If both maxwait and maxwaitunit are not specified, the maxwait is 3 minutes (180000 milliseconds).</p>
<p>If the <code>timeoutproperty</code> attribute has been set, a
property of that name will be created if the condition didn't come
true within the specified time.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -67,6 +70,12 @@ if multiple conditions are specified, then the task will wait until all conditio
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">timeoutproperty</td>
<td valign="top">the name of the property to set if maxwait has
been exceeded.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3><a name="nested">Nested Elements</a></h3>



+ 12
- 1
src/main/org/apache/tools/ant/taskdefs/WaitFor.java View File

@@ -74,6 +74,7 @@ import java.util.Hashtable;
* <li>maxwaitunit - The unit to be used to interpret maxwait attribute</li>
* <li>checkevery - amount of time to sleep between each check</li>
* <li>checkeveryunit - The unit to be used to interpret checkevery attribute</li>
* <li>timeoutproperty - name of a property to set if maxwait has been exceeded.</li>
* </ul>
*
* The maxwaitunit and checkeveryunit are allowed to have the following values:
@@ -88,6 +89,7 @@ public class WaitFor extends ConditionBase {
private long maxWaitMultiplier = 1l;
private long checkEveryMillis = 500l;
private long checkEveryMultiplier = 1l;
private String timeoutProperty;

/**
* Set the maximum length of time to wait
@@ -117,6 +119,13 @@ public class WaitFor extends ConditionBase {
checkEveryMultiplier = unit.getMultiplier();
}

/**
* Set the timeout property.
*/
public void setTimeoutProperty(String p) {
timeoutProperty = p;
}

/**
* Check repeatedly for the specified conditions until they become
* true or the timeout expires.
@@ -145,7 +154,9 @@ public class WaitFor extends ConditionBase {
}
}

throw new BuildException("Task did not complete in time");
if (timeoutProperty != null) {
project.setNewProperty(timeoutProperty, "true");
}
}

public static class Unit extends EnumeratedAttribute {


Loading…
Cancel
Save