This file is indexed.

/usr/share/doc/libantelope-java/manual/bk03ch05.html is in libantelope-java-doc 3.5.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 5. If Task</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch04.html" title="Chapter 4. Assert Task"><link rel="next" href="bk03ch05s02.html" title="More Conditions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. If Task</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch04.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch05s02.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="IfTask"></a>Chapter 5. If Task</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><ul class="toc"><li><span class="section"><a href="bk03ch05.html#idp62101440">If</a></span></li><li><span class="section"><a href="bk03ch05s02.html">More Conditions</a></span></li></ul></div>
@style@
    <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp62101440"></a>If</h2></div></div></div><p>
The If task provides a greatly improved "if" capability to Ant projects. This task works in a manner very similar to the Java <code class="computeroutput">if</code> keyword. This is useful for performing certain tasks only if a property has a specific value or certain conditions are met.
</p><p>
This task can hold other tasks including the If task. In particular, it can also have a single "else", which gives Ant a Java-like if/else construct, and a single "bool", which can be used for the "if" boolean expression.
</p><p>
To use this task in your build files, include a task definition like this:
</p><p>
</p><pre class="programlisting">

    &lt;taskdef name="if" classname="ise.antelope.tasks.IfTask"/&gt;
   
</pre><p>
</p><p>
An If task may contain only one 'bool' and one 'else' and may contain a 'break'. The 'bool' element is identical to the ConditionTask, but unlike the ConditionTask, is actually a Task. The 'bool' element can contain all the conditions permitted by the ConditionTask, plus the <a class="link" href="bk03ch05s02.html" title="More Conditions">IsPropertyTrue</a>, <a class="link" href="bk03ch05s02.html" title="More Conditions">IsPropertyFalse</a>,
<a class="link" href="bk03ch05s02.html" title="More Conditions">StartsWith</a>,
<a class="link" href="bk03ch05s02.html" title="More Conditions">EndsWith</a>,
<a class="link" href="bk03ch05s02.html" title="More Conditions">IsGreaterThan</a>,
<a class="link" href="bk03ch05s02.html" title="More Conditions">IsLessThan</a> and conditions.
</p><p>
Here is a general outline of the If task:
</p><pre class="programlisting">

&lt;if&gt;
    &lt;bool&gt;
        &lt;some condition(s)/&gt;
    &lt;/bool&gt;

    some tasks...

    &lt;!-- a break is allowed
    &lt;break/&gt;
    --&gt;

    &lt;else&gt;
        some other tasks...

        &lt;!-- a break is allowed
        &lt;break/&gt;
        --&gt;
    &lt;/else&gt;
&lt;/if&gt;

</pre><p>
</p><p>

</p><div class="table"><a name="idp62111712"></a><p class="title"><b>Table 5.1. If Task Attributes</b></p><div class="table-contents"><table summary="If 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>name</td><td>The name of the property to test for.</td><td>none</td><td>Yes, unless nested bool is used.</td></tr><tr><td>exists</td><td>Test for existence or non-existence of the property.</td><td>True</td><td>No</td></tr><tr><td>value</td><td>The value to test for, implies 'exists=true'. If the value for the property in the project is the same as this value, embedded tasks will be executed.</td><td>none</td><td>No</td></tr></tbody></table></div></div><p><br class="table-break">

</p><p>
The If task can hold any number of Ant tasks. If the property value is correct or the "bool" element evaluates to true, these tasks will be executed.
</p><p>
In addition, the If task supports three special nested elements:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
<span class="bold"><strong>bool</strong></span> This is very similar to the standard Ant Condition task. All conditions supported by the Condition task are supported by the bool element. This is an optional element and if used, is used to decide if the "if" tasks or the "else" tasks should be executed. If the bool element is not used, then the "name" attribute must be used.
</p></li><li class="listitem"><p>
<span class="bold"><strong>else</strong></span> This is very similar to the standard Ant Sequential task. The "else" can hold any number of Ant tasks. These tasks are executed if the "bool" element evaluates to false.
</p></li><li class="listitem"><p>
<span class="bold"><strong>break</strong></span> This is very similar to the Java "break" keyword. This is only useful if the If task is nested in another task that understands "break", such as the <a class="link" href="bk03ch06.html" title="Chapter 6. SwitchTask">Switch</a> task. Like the Java "break", when this element is encountered, no subsequent tasks will be executed and control passes outside the If.
</p></li></ul></div><p>
In the following example, the <code class="computeroutput">antcall</code> task will execute only if the project has a property named <code class="computeroutput">test</code> with a value of <code class="computeroutput">true</code>.
</p><p>
</p><pre class="programlisting">
   
   &lt;if name="test" value="true"&gt;
      &lt;antcall target="doUnitTests"/&gt;
   &lt;/if&gt;
   
</pre><p>
</p><p>
In the next example, the <code class="computeroutput">antcall</code> task will execute only if the project has a property named <code class="computeroutput">test</code>. In this example, it does not matter what value is assigned to the <code class="computeroutput">test</code> property.
</p><p>
</p><pre class="programlisting">
    
   &lt;if name="test"&gt;
      &lt;antcall target="doUnitTests"/&gt;
   &lt;/if&gt;
   
</pre><p>
</p><p>
Of course, the same thing could have been done as follows, but the "if" is generally much cleaner.
</p><pre class="programlisting">
   
   &lt;antcall target="doUnitTests"/&gt;
   &lt;target name="doUnitTests" if="test"&gt;
      ...
   &lt;/target&gt;
   
</pre><p>
</p><p>
In the next example, the <code class="computeroutput">antcall</code> task will execute only if the project does not have a property named <code class="computeroutput">test</code>. This is the opposite situation of the previous example.
</p><p>
</p><pre class="programlisting">
   
   &lt;if name="test" exists="false"&gt;
      &lt;antcall target="doUnitTests"/&gt;
   &lt;/if&gt;
   
</pre><p>
</p><p>
The next example demonstrates nested 'if' tasks. This example will run the unit tests, and if it is Monday, will publish the accumulated test results.
</p><p>
</p><pre class="programlisting">
    
   &lt;tstamp&gt;
      &lt;format property="day" pattern="E" /&gt;
   &lt;/tstamp&gt;
   &lt;if name="test" value="true"&gt;
      &lt;antcall target="doUnitTests"/&gt;
      &lt;if name="day" value="Mon"&gt;
         &lt;antcall target="publishTestResults"/&gt;
      &lt;/if&gt;
   &lt;/if&gt;
   
</pre><p>
</p><p>
The next example shows how to use If with Else. Notice that it doesn't matter where the Else is placed inside the If. All tasks in the If that are not in the Else will execute if the property value is correct, otherwise, only those tasks inside the else will execute. The "var" task is discussed <a class="link" href="bk03ch09.html" title="Chapter 9. Variable Task">here</a>.
</p><p>
</p><pre class="programlisting">
    
    &lt;var name="foo" value="bar"/&gt;
    &lt;if name="foo" value="bar"&gt;
        &lt;echo&gt;this will happen&lt;/echo&gt;
        &lt;else&gt;
            &lt;echo&gt;this won't happen&lt;/echo&gt;
        &lt;/else&gt;
        &lt;echo&gt;this will happen also&lt;/echo&gt;
    &lt;/if&gt;

    &lt;if name="foo" value="snarf"&gt;
        &lt;echo&gt;this won't happen&lt;/echo&gt;
        &lt;else&gt;
            &lt;echo&gt;this 'else' will happen&lt;/echo&gt;
            &lt;echo&gt;and so will this&lt;/echo&gt;
        &lt;/else&gt;
        &lt;echo&gt;this won't happen either&lt;/echo&gt;
    &lt;/if&gt;
    
</pre><p>
</p><p>
The next example shows the "if" and "assert" tasks working together to validate a property before use, and also shows an example of where the "assert" 'failonerror' attribute might be useful. In this example, if the e-mail address is invalid, the e-mail won't be sent and the build won't fail. The "try" task is discussed <a class="link" href="bk03ch07.html" title="Chapter 7. Try Task">here</a>.
</p><p>
</p><pre class="programlisting">
    
   &lt;if name="email_from" value="buildteam@mycompany.com"&gt;
      &lt;property name="valid_email" value="true"/&gt;
   &lt;/if&gt;
   &lt;if name="email_from" value="buildsite@mycompany.com"&gt;
      &lt;property name="valid_email" value="true"/&gt;
   &lt;/if&gt;
   &lt;assert name="valid_email" value="true" failonerror="false"&gt;
      &lt;try&gt;
          &lt;mail from="${email_from}" tolist="${email_to}"
              message="New release available"/&gt;
      &lt;/try&gt;
   &lt;/assert&gt;
   
</pre><p>
</p><p>
Here is the same thing, but using only If and Else:
</p><p>
</p><pre class="programlisting">
    
   &lt;try&gt;
       &lt;if name="email_from" value="buildteam@mycompany.com"&gt;
          &lt;mail from="${email_from}" tolist="${email_to}"
              message="New release available"/&gt;
          &lt;else&gt;
             &lt;if name="email_from" value="buildsite@mycompany.com"&gt;
                 &lt;mail from="${email_from}" tolist="${email_to}"
                      message="New release available"/&gt;
             &lt;/if&gt;
          &lt;/else&gt;
       &lt;/if&gt;
   &lt;/try&gt;
   
</pre><p>
</p><p>
The next example shows how to use the "bool" element:
</p><p>
</p><pre class="programlisting">
    
    &lt;if&gt;
        &lt;!-- "if" evaluates this element --&gt;
        &lt;bool&gt;
            &lt;and&gt;
                &lt;available file="build.xml"/&gt;
                &lt;available file="run.xml"/&gt;
            &lt;/and&gt;
        &lt;/bool&gt;

        &lt;!-- if true, then tasks listed here will execute --&gt;
        &lt;echo&gt;build.xml and run.xml are available&lt;/echo&gt;

        &lt;!-- if false, then tasks inside the "else" will execute --&gt;
        &lt;else&gt;
            &lt;echo&gt;didn't find one or both of build.xml and run.xml&lt;/echo&gt;
        &lt;/else&gt;
    &lt;/if&gt;
    
</pre><p>
</p><p>
The following example shows the "bool" element again:
</p><p>
</p><pre class="programlisting">
    
    &lt;if&gt;
        &lt;bool&gt;
            &lt;equals arg1="${download.dir}" arg2="test.dir"/&gt;
        &lt;/bool&gt;

        &lt;fail message="Download and test directories cannot be
            the same! You need to reset to use the production
            property set."/&gt;

        &lt;else&gt;
            &lt;copy file="installer.zip" todir="${download.dir}"/&gt;
        &lt;/else&gt;
    &lt;/if&gt;
    
</pre><p>
</p><p>
The following example is from the unit test for the "Limit" task. It shows the Stopwatch task, the Limit task, and the If task with boolean conditions:
</p><p>
</p><pre class="programlisting">
    
  &lt;target name="test2"&gt;
    &lt;!-- should not stop 'sleep' task, should print out '_passed_' --&gt;
    &lt;stopwatch name="timer"/&gt;
    &lt;limit maxwait="5"&gt;
        &lt;sleep seconds="1"/&gt;
        &lt;echo&gt;_passed_&lt;/echo&gt;
    &lt;/limit&gt;
    &lt;stopwatch name="timer" action="total"/&gt;
    &lt;if&gt;
        &lt;bool&gt;
            &lt;isgreaterthan arg1="${timer}" arg2="2"/&gt;
        &lt;/bool&gt;
        &lt;fail message="Too much time"/&gt;
    &lt;/if&gt;
  &lt;/target&gt;
    
</pre><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Assert Task </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> More Conditions</td></tr></table></div></body></html>