org.apache.tools.ant.taskdefs

Class ConditionTask

Implemented Interfaces:
Cloneable, DynamicElement

public class ConditionTask
extends ConditionBase

Task to set a property conditionally using <uptodate>, <available>, and many other supported conditions.

This task supports boolean logic as well as pluggable conditions to decide, whether a property should be set.

This task does not extend Task to take advantage of ConditionBase.

Since:
Ant 1.4

Field Summary

Fields inherited from class org.apache.tools.ant.ProjectComponent

description, location, project

Constructor Summary

ConditionTask()
Constructor, names this task "condition".

Method Summary

void
execute()
See whether our nested condition holds and set the property.
void
setElse(String e)
The value for the property to set, if condition evaluates to false.
void
setProperty(String p)
The name of the property to set.
void
setValue(String v)
The value for the property to set, if condition evaluates to true.

Methods inherited from class org.apache.tools.ant.taskdefs.condition.ConditionBase

add, addAnd, addAvailable, addChecksum, addContains, addEquals, addFilesMatch, addHttp, addIsFalse, addIsFileSelected, addIsReference, addIsSet, addIsTrue, addNot, addOr, addOs, addSocket, addUptodate, countConditions, createDynamicElement, getConditions, getTaskName, setTaskName

Methods inherited from class org.apache.tools.ant.ProjectComponent

clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject

Constructor Details

ConditionTask

public ConditionTask()
Constructor, names this task "condition".

Method Details

execute

public void execute()
            throws BuildException
See whether our nested condition holds and set the property.
Throws:
BuildException - if an error occurs
Since:
Ant 1.4

setElse

public void setElse(String e)
The value for the property to set, if condition evaluates to false. If this attribute is not specified, the property will not be set.
Parameters:
e - the alternate value of the property.
Since:
Ant 1.6.3

setProperty

public void setProperty(String p)
The name of the property to set. Required.
Parameters:
p - the name of the property
Since:
Ant 1.4

setValue

public void setValue(String v)
The value for the property to set, if condition evaluates to true. Defaults to "true".
Parameters:
v - the value of the property
Since:
Ant 1.4