Chapter 11. Limit

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.

To use this task in your build files, include a task definition like this:


    <taskdef name="limit" classname="ise.antelope.tasks.Limit"/>
   

Table 11.1. Limit Task Attributes

AttributeDescriptionDefaultRequired
maxwaitHow long to wait for nested tasks to finish, this is in seconds.180 seconds (3 minutes)No
failonerrorShould the build fail if the time limit has been exceeded?falseNo

Examples:

Neither the echo nor the fail will happen in this example. The build will continue once the time has expired.


<limit maxwait="3">
   <sleep seconds="10"/>
   <echo>This won't happen...</echo>
   <fail>This won't happen either...</fail>
</limit>

Neither the echo nor the fail will happen in this example. The build will not continue once the time has expired.


<limit maxwait="3" failonerror="true">
   <sleep seconds="10"/>
   <echo>This won't happen...</echo>
   <fail>This won't happen either...</fail>
</limit>