Changeset 98

Show
Ignore:
Timestamp:
07/14/06 15:54:45 (2 years ago)
Author:
bernhard
Message:

#46:

* Describe conditions
* Document the condition and the if tasks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/docs/phing_guide/book/chapters/ProjectComponents.html

    r1 r98  
    355355  C</a>.</p> 
    356356 
     357<h2><a name="Conditions">Conditions</a></h2> 
     358 
     359<p>Conditions are nested elements of the  
     360<a href="appendixes/AppendixB-CoreTasks.html#ConditionTask">condition</code></a> and 
     361<a href="appendixes/AppendixB-CoreTasks.html#IfTask">if</a> tasks. 
     362</p> 
     363 
     364<h4>not</h4> 
     365<p>The <code>&lt;not&gt;</code> element expects exactly one other 
     366condition to be nested into this element, negating the result of the 
     367condition. It doesn't have any attributes and accepts all nested 
     368elements of the condition task as nested elements as well.</p> 
     369 
     370<h4>and</h4> <p> 
     371The <code>&lt;and&gt;</code> element doesn't have any attributes and 
     372accepts an arbitrary number of conditions as nested elements. This condition 
     373is true if all of its contained conditions are, conditions will be 
     374evaluated in the order they have been specified in the build file.</p> 
     375 
     376<p>The <code>&lt;and&gt;</code> condition has the same shortcut 
     377semantics as the &amp;&amp; operator in some programming languages, as soon as one of the 
     378nested conditions is false, no other condition will be evaluated.</p> 
     379 
     380<h4>or</h4> <p> 
     381The <code>&lt;or&gt;</code> element doesn't have any attributes and 
     382accepts an arbitrary number of conditions as nested elements. This condition 
     383is true if at least one of its contained conditions is, conditions 
     384will be evaluated in the order they have been specified in the build 
     385file.</p> 
     386 
     387<p>The <code>&lt;or&gt;</code> condition has the same 
     388shortcut semantics as the || operator in some programming languages, as soon as one of the 
     389nested conditions is true, no other condition will be evaluated.</p> 
     390 
     391<h4>available</h4> 
     392<p>This condition is identical to the <a 
     393href="appendixes/AppendixB-CoreTasks.html#AvailableTask">Available</a> task, all attributes and nested 
     394elements of that task are supported, the property and value attributes 
     395are redundant and will be ignored.</p> 
     396 
     397<h4>uptodate</h4> 
     398<p>This condition is identical to the <a 
     399href="appendixes/AppendixB-CoreTasks.html#UpToDateTask">UpToDate</a> task, all attributes and nested 
     400elements of that task are supported, the property and value attributes 
     401are redundant and will be ignored.</p> 
     402 
     403<h4>os</h4> 
     404<p>Test whether the current operating system is of a given type.</p> 
     405 
     406<table border="1" cellpadding="2" cellspacing="0"> 
     407  <tr> 
     408    <td valign="top"><b>Attribute</b></td> 
     409    <td valign="top"><b>Description</b></td> 
     410    <td align="center" valign="top"><b>Required</b></td> 
     411  </tr> 
     412  <tr> 
     413    <td valign="top">family</td> 
     414    <td valign="top">The name of the operating system family to expect.</td> 
     415    <td valign="top" align="center">Yes</td> 
     416  </tr> 
     417</table> 
     418<p>Supported values for the family attribute are: 
     419<ul> 
     420  <li>windows (for all versions of Microsoft Windows)</li> 
     421  <li>mac (for all Apple Macintosh systems)</li> 
     422  <li>unix (for all Unix and Unix-like operating systems)</li> 
     423</ul> 
     424 
     425<h4>equals</h4> 
     426<p>Tests whether the two given Strings are identical</p> 
     427<table border="1" cellpadding="2" cellspacing="0"> 
     428  <tr> 
     429    <td valign="top"><b>Attribute</b></td> 
     430    <td valign="top"><b>Description</b></td> 
     431    <td align="center" valign="top"><b>Required</b></td> 
     432  </tr> 
     433  <tr> 
     434    <td valign="top">arg1</td> 
     435    <td valign="top">First string to test.</td> 
     436    <td valign="top" align="center">Yes</td> 
     437  </tr> 
     438  <tr> 
     439    <td valign="top">arg2</td> 
     440    <td valign="top">Second string to test.</td> 
     441    <td valign="top" align="center">Yes</td> 
     442  </tr> 
     443  <tr> 
     444    <td valign="top">casesensitive</td> 
     445    <td valign="top">Perform a case sensitive comparision.  Default is 
     446        true.</td> 
     447    <td valign="top" align="center">No</td> 
     448  </tr> 
     449  <tr> 
     450    <td valign="top">trim</td> 
     451    <td valign="top">Trim whitespace from arguments before comparing 
     452        them.  Default is false.</td> 
     453    <td valign="top" align="center">No</td> 
     454  </tr> 
     455</table> 
     456 
     457<h4>isset</h4> 
     458<p>Test whether a given property has been set in this project.</p> 
     459<table border="1" cellpadding="2" cellspacing="0"> 
     460  <tr> 
     461    <td valign="top"><b>Attribute</b></td> 
     462    <td valign="top"><b>Description</b></td> 
     463    <td align="center" valign="top"><b>Required</b></td> 
     464  </tr> 
     465  <tr> 
     466    <td valign="top">property</td> 
     467    <td valign="top">The name of the property to test.</td> 
     468    <td valign="top" align="center">Yes</td> 
     469  </tr> 
     470</table> 
     471 
     472<h4>contains</h4> 
     473<p>Tests whether a string contains another one.</p> 
     474<table border="1" cellpadding="2" cellspacing="0"> 
     475  <tr> 
     476    <td valign="top"><b>Attribute</b></td> 
     477    <td valign="top"><b>Description</b></td> 
     478    <td align="center" valign="top"><b>Required</b></td> 
     479  </tr> 
     480  <tr> 
     481    <td valign="top">string</td> 
     482    <td valign="top">The string to search in.</td> 
     483    <td valign="top" align="center">Yes</td> 
     484  </tr> 
     485  <tr> 
     486    <td valign="top">substring</td> 
     487    <td valign="top">The string to search for.</td> 
     488    <td valign="top" align="center">Yes</td> 
     489  </tr> 
     490  <tr> 
     491    <td valign="top">casesensitive</td> 
     492    <td valign="top">Perform a case sensitive comparision.  Default is 
     493        true.</td> 
     494    <td valign="top" align="center">No</td> 
     495  </tr> 
     496</table> 
     497 
     498<h4>istrue</h4> 
     499<p>Tests whether a string evals to true.</p> 
     500 
     501<table border="1" cellpadding="2" cellspacing="0"> 
     502  <tr> 
     503    <td valign="top"><b>Attribute</b></td> 
     504    <td valign="top"><b>Description</b></td> 
     505    <td align="center" valign="top"><b>Required</b></td> 
     506  </tr> 
     507  <tr> 
     508    <td valign="top">value</td> 
     509    <td valign="top">value to test</td> 
     510    <td valign="top" align="center">Yes</td> 
     511  </tr> 
     512</table> 
     513<pre> 
     514    &lt;istrue value=&quot;${someproperty}&quot;/&gt; 
     515    &lt;istrue value=&quot;false&quot;/&gt; 
     516</pre> 
     517 
     518<h4>isfalse</h4> 
     519<p>Tests whether a string evals to not true, the negation of &lt;istrue&gt; 
     520</p> 
     521<table border="1" cellpadding="2" cellspacing="0"> 
     522  <tr> 
     523    <td valign="top"><b>Attribute</b></td> 
     524    <td valign="top"><b>Description</b></td> 
     525    <td align="center" valign="top"><b>Required</b></td> 
     526  </tr> 
     527  <tr> 
     528    <td valign="top">value</td> 
     529    <td valign="top">value to test</td> 
     530    <td valign="top" align="center">Yes</td> 
     531  </tr> 
     532</table> 
     533<pre> 
     534    &lt;isfalse value=&quot;${someproperty}&quot;/&gt; 
     535    &lt;isfalse value=&quot;false&quot;/&gt; 
     536</pre> 
     537 
    357538</body> 
    358539</html> 
  • branches/2.2/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html

    r97 r98  
    297297--> 
    298298 
     299<h2><a name="ConditionTask"></a>ConditionTask</h2> 
     300<p>Sets a property if a certain condition holds true - this is a 
     301        generalization of <a href="#AvailableTask">Available</a> and  
     302        <a href="#UpToDateTask">UpToDate</a>.</p> 
     303<p>If the condition holds true, the property value is set to true by 
     304        default; otherwise, the property is not set. You can set the value to 
     305        something other than the default by specifying the <code>value</code> 
     306        attribute.</p> 
     307<p>Conditions are specified as nested elements, you must specify exactly  
     308        one condition - see the <a href="../ProjectComponents.html#Conditions">documentation</a>  
     309        for a complete list of nested elements.</p> 
     310<h3>Example</h3> 
     311<pre> 
     312&lt;condition property="isMacOrWindows"&gt; 
     313    &lt;and&gt; 
     314      &lt;os family="mac"/&gt; 
     315      &lt;os family="windows"/&gt; 
     316    &lt;/and&gt; 
     317  &lt;/condition&gt; 
     318</pre> 
     319<h3>Attributes</h3> 
     320<table> 
     321  <thead> 
     322    <tr> 
     323      <th>Name</th> 
     324      <th>Type</th> 
     325      <th>Description</th> 
     326      <th>Default</th> 
     327      <th>Required</th> 
     328    </tr> 
     329  </thead> 
     330  <tbody> 
     331    <tr> 
     332      <td>property</td> 
     333      <td>String</td> 
     334      <td>The name of the property to set.</td> 
     335      <td>n/a</td> 
     336      <td>Yes</td> 
     337    </tr> 
     338    <tr> 
     339      <td>value</td> 
     340      <td>String</td> 
     341      <td>The value to set the property to. Defaults to "true".</td> 
     342      <td>true</td> 
     343      <td>No</td> 
     344    </tr> 
     345  </tbody> 
     346</table> 
     347 
    299348<h2><a name="CopyTask"></a>CopyTask</h2> 
    300349<p> 
     
    778827  </tbody> 
    779828</table> 
     829 
     830<h2><a name="IfTask"></a>IfTask</h2> 
     831<p>Perform some tasks based on whether a given condition holds true or not.</p> 
     832<h3>Attributes</h3> 
     833<p> 
     834This task doesn't have any attributes, the condition to test is specified by a nested 
     835        element - see the <a href="../ProjectComponents.html#Conditions">documentation</a>  
     836        for a complete list of nested elements.</p> 
     837<p>Just like the <code>&lt;condition&gt;</code> task, only a 
     838    single condition can be specified - you combine them using 
     839    <code>&lt;and&gt;</code> or <code>&lt;or&gt;</code> 
     840    conditions.</p> 
     841<p>In addition to the condition, you can specify three different 
     842    child elements, <code>&lt;elseif&gt;</code>, <code>&lt;then&gt;</code> and 
     843    <code>&lt;else&gt;</code>.  All three subelements are optional. 
     844 
     845    Both <code>&lt;then&gt;</code> and <code>&lt;else&gt;</code> must not be 
     846    used more than once inside the if task. Both are 
     847    containers for Phing tasks.</p> 
     848 
     849<p>The <code>&lt;elseif&gt;</code> behaves exactly like an <code>&lt;if&gt;</code> 
     850    except that it cannot contain the <code>&lt;else&gt;</code> element 
     851    inside of it.  You may specify as may of these as you like, and the 
     852    order they are specified is the order they are evaluated in.  If the 
     853    condition on the <code>&lt;if&gt;</code> is false, then the first 
     854    <code>&lt;elseif&gt;</code> who's conditional evaluates to true 
     855    will be executed.  The <code>&lt;else&gt;</code> will be executed 
     856    only if the <code>&lt;if&gt;</code> and all <code>&lt;elseif&gt;</code> 
     857    conditions are false.</p> 
     858<h3>Example</h3> 
     859<pre> 
     860&lt;if&gt; 
     861 &lt;equals arg1="${foo}" arg2="bar" /&gt; 
     862 &lt;then&gt; 
     863   &lt;echo message="The value of property foo is bar" /&gt; 
     864 &lt;/then&gt; 
     865 &lt;else&gt; 
     866   &lt;echo message="The value of property foo is not bar" /&gt; 
     867 &lt;/else&gt; 
     868&lt;/if&gt; 
     869</pre> 
     870 
     871<pre> 
     872&lt;if&gt; 
     873 &lt;equals arg1="${foo}" arg2="bar" /&gt; 
     874 &lt;then&gt; 
     875   &lt;echo message="The value of property foo is 'bar'" /&gt; 
     876 &lt;/then&gt; 
     877 
     878 &lt;elseif&gt; 
     879  &lt;equals arg1="${foo}" arg2="foo" /&gt; 
     880  &lt;then&gt; 
     881   &lt;echo message="The value of property foo is 'foo'" /&gt; 
     882  &lt;/then&gt; 
     883 &lt;/elseif&gt; 
     884 
     885 &lt;else&gt; 
     886   &lt;echo message="The value of property foo is not 'foo' or 'bar'" /&gt; 
     887 &lt;/else&gt; 
     888&lt;/if&gt; 
     889</pre> 
    780890 
    781891<h2><a name="IncludePathTask"></a>IncludePathTask</h2> 
  • branches/2.2/docs/phing_guide/book/toc/FrameToC.html

    r88 r98  
    6060<li><a href="../chapters/ProjectComponents.html#Types" target="Content">Types</a></li> 
    6161<li><a href="../chapters/ProjectComponents.html#BasicTypes" target="Content">Basic Types</a></li> 
     62<li><a href="../chapters/ProjectComponents.html#Conditions" target="Content">Conditions</a></li> 
    6263</ul> 
    6364</ul> 
     
    9394<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#AvailableTask" target="Content">AvailableTask</a></li> 
    9495<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#CallTargetTask" target="Content">CallTargetTask</a></li> 
     96<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ConditionTask" target="Content">ConditionTask</a></li> 
    9597<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#CopyTask" target="Content">CopyTask</a></li> 
    9698<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#DeleteTask" target="Content"> DeleteTask</a></li> 
     
    99101<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ExitTask" target="Content">ExitTask</a></li> 
    100102<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ForeachTask" target="Content">ForeachTask</a></li> 
     103<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#IfTask" target="Content">IfTask</a></li> 
    101104<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#IncludePathTask" target="Content">IncludePathTask</a></li> 
    102105<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#InputTask" target="Content">InputTask</a></li> 
  • branches/2.2/docs/phing_guide/book/toc/ToC.html

    r88 r98  
    4545<li><a href="../chapters/ProjectComponents.html#Types">Types</a></li> 
    4646<li><a href="../chapters/ProjectComponents.html#BasicTypes">Basic Types</a></li> 
     47<li><a href="../chapters/ProjectComponents.html#Conditions">Conditions</a></li> 
    4748</ul> 
    4849</ul> 
     
    7879<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#AvailableTask">AvailableTask</a></li> 
    7980<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#CallTargetTask">CallTargetTask</a></li> 
     81<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ConditionTask">ConditionTask</a></li> 
    8082<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#CopyTask">CopyTask</a></li> 
    8183<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#DeleteTask"> DeleteTask</a></li> 
     
    8486<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ExitTask">ExitTask</a></li> 
    8587<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ForeachTask">ForeachTask</a></li> 
     88<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#IfTask">IfTask</a></li> 
    8689<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#IncludePathTask">IncludePathTask</a></li> 
    8790<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#InputTask">InputTask</a></li>