IfTask

Extends \ConditionBase

Perform some tasks based on whether a given condition holds true or not.

This task is heavily based on the Condition framework that can be found in Ant 1.4 and later, therefore it cannot be used in conjunction with versions of Ant prior to 1.4.

This task doesn't have any attributes, the condition to test is specified by a nested element - see the documentation of your task (see the online documentation for example) for a complete list of nested elements.

Just like the task, only a single condition can be specified - you combine them using or conditions.

In addition to the condition, you can specify three different child elements, , and . All three subelements are optional. Both and must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's and tasks - in fact they are implemented using the same class as Ant's task.

The <elseif> behaves exactly like an <if> except that it cannot contain the <else> element inside of it. You may specify as may of these as you like, and the order they are specified is the order they are evaluated in. If the condition on the <if> is false, then the first <elseif> who's conditional evaluates to true will be executed. The <else> will be executed only if the <if> and all <elseif> conditions are false.

Use the following task to define the task before you use it the first time:


  <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />

Crude Example

author

Stefan Bodewig

package

phing.tasks.system

Methods

addElseIf

addElseIf(\ElseIfTask $ei) 

Arguments

A nested <then> element - a container of tasks that will be run if the condition holds true.

addThen(\SequentialTask $t) 

Not required.

Arguments

A nested <else> element - a container of tasks that will be run if the condition doesn't hold true.

addElse(\SequentialTask $e) 

Not required.

Arguments

main

main() 

countConditions

countConditions() 
inherited

Required for IteratorAggregate

getIterator() 
inherited

getConditions

getConditions() 
inherited

addAvailable

addAvailable(\AvailableTask $a) : void
inherited

Arguments

createNot

createNot() : \NotCondition
inherited

Response

\NotCondition

createAnd

createAnd() : \AndCondition
inherited

Response

\AndCondition

createOr

createOr() : \OrCondition
inherited

Response

\OrCondition

createEquals

createEquals() : \EqualsCondition
inherited

Response

\EqualsCondition

createOs

createOs() : \OsCondition
inherited

Response

\OsCondition

createIsFalse

createIsFalse() : \IsFalseCondition
inherited

createIsTrue

createIsTrue() : \IsTrueCondition
inherited

Response

\IsTrueCondition

createContains

createContains() : \ContainsCondition
inherited

createIsSet

createIsSet() : \IsSetCondition
inherited

Response

\IsSetCondition

createReferenceExists

createReferenceExists() : \ReferenceExistsCondition
inherited

customChildCreator

customChildCreator(string $elementName, \Project $project) : \Condition
inherited
throws

Arguments

$elementName

string

$project

\Project

Response

\Condition

References the project to the current component.

setProject(\Project $project) 
inherited

Arguments

$project

\Project

The reference to the current project

Returns a reference to current project

getProject() : \Project
inherited

Response

\Project

Reference to current porject object

Logs a message with the given priority.

log(string $msg, integer $level = \Project::MSG_INFO) 
inherited

Arguments

$msg

string

The message to be logged.

$level

integer

The message's priority at this message should have

Properties

thenTasks

thenTasks : 

elseIfTasks

elseIfTasks : 

elseTasks

elseTasks : 

conditions

conditions : 
inherited

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

project : \Project
inherited
var

A reference to the current project instance

Type(s)

\Project