Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 16e567b9c4f399396e323ecd14733323 > files > 21

ant-contrib-1.0-0.12.b3.1.mga2.noarch.rpm

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>
Chapter&nbsp;10.&nbsp;Limit</title>
<meta content="DocBook XSL Stylesheets V1.60.1" name="generator">
<link rel="home" href="index.html" title="Antelope Users Guide">
<link rel="up" href="bk03.html" title="Additional Ant Tasks">
<link rel="previous" href="bk03ch09.html" title="Chapter&nbsp;9.&nbsp;Stopwatch">
<link rel="next" href="bk03ch11.html" title="Chapter&nbsp;11.&nbsp;Math">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="chapter" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="Limit">
</a>
Limit</h2>
</div>
</div>
<div>
</div>
</div>
<p>

The Limit task is a task container (that is, it holds other tasks) and sets a time limit on how long the nested tasks are allowed to run. This is useful for unit tests that go awry, hung socket connections, or other potentially long running tasks that need to be shut off without stopping the build.
</p>

<p>

<div class="table">
<a name="N1096A">
</a>
<p class="title">
<b>
Table&nbsp;10.1.&nbsp;Limit Task Attributes</b>
</p>
<table summary="Limit Task Attributes" border="1">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>
Attribute</th>
<th>
Description</th>
<th>
Default</th>
<th>
Required</th>
</tr>
</thead>
<tbody>
<tr>
<td>
maxwait</td>
<td>
How long to wait for nested tasks to finish.</td>
<td>
180 seconds (3 minutes)</td>
<td>
No</td>
</tr>

<tr>
<td>
maxwaitunit</td>
<td>
The unit for maxwait. Valid values are "millisecond", "second", "minute", "hour", "day", "week".</td>
<td>
seconds</td>
<td>
No</td>
</tr>

<tr>
<td>
failonerror</td>
<td>
Should the build fail if the time limit has been exceeded?</td>
<td>
false</td>
<td>
No</td>
</tr>

<tr>
<td>
property</td>
<td>
The name of a property to set if the max wait time is exceeded.</td>
<td>
none</td>
<td>
No</td>
</tr>

<tr>
<td>
value</td>
<td>
The value to set for the property if the max wait time is exceeded.</td>
<td>
true</td>
<td>
No</td>
</tr>

<tr>
<td>
milliseconds</td>
<td>
How long to wait in milliseconds.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>

<tr>
<td>
seconds</td>
<td>
How long to wait in seconds.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>

<tr>
<td>
minutes</td>
<td>
How long to wait in minutes.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>

<tr>
<td>
hours</td>
<td>
How long to wait in hours.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>

<tr>
<td>
days</td>
<td>
How long to wait in days.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>

<tr>
<td>
weeks</td>
<td>
How long to wait in weeks.</td>
<td>
3 minutes</td>
<td>
No</td>
</tr>


</tbody>
</table>
</div>

</p>
<p>

Examples:
</p>
<p>

Neither the echo nor the fail will happen in this example. The build will continue once the time has expired.
<table border="0" bgcolor="#E0E0E0">
<tr>
<td>
<pre class="programlisting">


&lt;limit maxwait="3"&gt;
   &lt;sleep seconds="10"/&gt;
   &lt;echo&gt;This won't happen...&lt;/echo&gt;
   &lt;fail&gt;This won't happen either...&lt;/fail&gt;
&lt;/limit&gt;

</pre>
</td>
</tr>
</table>

</p>
<p>

This is identical to the above example, but uses the convenience "seconds" attribute:
<table border="0" bgcolor="#E0E0E0">
<tr>
<td>
<pre class="programlisting">


&lt;limit seconds="3"&gt;
   &lt;sleep seconds="10"/&gt;
   &lt;echo&gt;This won't happen...&lt;/echo&gt;
   &lt;fail&gt;This won't happen either...&lt;/fail&gt;
&lt;/limit&gt;

</pre>
</td>
</tr>
</table>

</p>
<p>

Neither the echo nor the fail will happen in this example. The build will not continue once the time has expired.
<table border="0" bgcolor="#E0E0E0">
<tr>
<td>
<pre class="programlisting">


&lt;limit maxwait="3" failonerror="true"&gt;
   &lt;sleep seconds="10"/&gt;
   &lt;echo&gt;This won't happen...&lt;/echo&gt;
   &lt;fail&gt;This won't happen either...&lt;/fail&gt;
&lt;/limit&gt;

</pre>
</td>
</tr>
</table>

</p>
<p>

The limit will be reached and a property will be set indicating so.
<table border="0" bgcolor="#E0E0E0">
<tr>
<td>
<pre class="programlisting">


&lt;limit minutes="3" property="limit_reached"&gt;
   &lt;sleep minutes="10"/&gt;
   &lt;echo&gt;This won't happen...&lt;/echo&gt;
   &lt;fail&gt;This won't happen either...&lt;/fail&gt;
&lt;/limit&gt;
&lt;echo&gt;limit_reached = ${limit_reached)&lt;/echo&gt;
</pre>
</td>
</tr>
</table>

</p>
</div>
    <hr>
    <p align="center">Copyright &copy; 2003-2004 Ant-Contrib Project. All
    rights Reserved.</p>
</body>
</html>