equal
deleted
inserted
replaced
|
1 <?xml version="1.0"?> |
|
2 <project name="SF-RETRY" default="all" xmlns:hlm="http://www.nokia.com/helium"> |
|
3 |
|
4 <dirname property="sf.retry.dir" file="${ant.file.SF-RETRY}"/> |
|
5 |
|
6 <macrodef name="retry"> |
|
7 <attribute name="tries" default="3" description="How many times to try the nested script"/> |
|
8 <attribute name="uniquename" description="An identifier specific to this thread, or a constant for single-threaded contexts"/> |
|
9 <attribute name="failonerror" default="true" description="Set to false to avoid an abort after all attempts"/> |
|
10 <element name="sequential" description="The tasks to retry"/> |
|
11 <element name="cleanup" optional="true" description="Tasks to run to clean up after a failed try"/> |
|
12 <sequential> |
|
13 <trycatch reference="exception.@{uniquename}.ref" property="exception.@{uniquename}.prop"> |
|
14 <try> |
|
15 <sequential/> |
|
16 </try> |
|
17 <catch> |
|
18 <math result="newtries.@{uniquename}" operation="-" operand2="@{tries}" operand1="1" datatype="int"/> |
|
19 <if> |
|
20 <not> |
|
21 <equals arg1="${newtries.@{uniquename}}" arg2="0"/> |
|
22 </not> |
|
23 <then> |
|
24 <!-- Clean up ready to try again --> |
|
25 <cleanup/> |
|
26 <sleep seconds="1"/> |
|
27 <!-- Recurse (via helper) --> |
|
28 <retry-helper tries="${newtries.@{uniquename}}" uniquename="@{uniquename}" failonerror="@{failonerror}"> |
|
29 <sequence> |
|
30 <sequential/> |
|
31 </sequence> |
|
32 <cleanup-helper> |
|
33 <cleanup/> |
|
34 </cleanup-helper> |
|
35 </retry-helper> |
|
36 </then> |
|
37 <else> |
|
38 <if> |
|
39 <istrue value="@{failonerror}"/> |
|
40 <then> |
|
41 <throw refid="exception.@{uniquename}.ref"/> |
|
42 </then> |
|
43 </if> |
|
44 </else> |
|
45 </if> |
|
46 </catch> |
|
47 </trycatch> |
|
48 </sequential> |
|
49 </macrodef> |
|
50 <macrodef name="retry-helper" description="Don't use this directly, use 'retry'"> |
|
51 <attribute name="tries"/> |
|
52 <attribute name="uniquename"/> |
|
53 <attribute name="failonerror"/> |
|
54 <element name="sequence"/> |
|
55 <element name="cleanup-helper"/> |
|
56 <sequential> |
|
57 <retry tries="@{tries}" uniquename="@{uniquename}" failonerror="@{failonerror}"> |
|
58 <sequential> |
|
59 <sequence/> |
|
60 </sequential> |
|
61 <cleanup> |
|
62 <cleanup-helper/> |
|
63 </cleanup> |
|
64 </retry> |
|
65 </sequential> |
|
66 </macrodef> |
|
67 |
|
68 </project> |