tasks/system/PropertyTask.php
Task for setting properties in buildfiles.
- Author
- Andreas Aderhold
- Author
- Hans Lellelid
- Package
- phing.tasks.system
- Version
- $Id: e6d7123b6331d5032ad1e67967cf54ef2aae3f7f $
\PropertyTask
Task for setting properties in buildfiles.
Use {@link Project#createTask} to register a new Task.
- Parent(s)
- \Task < \ProjectComponent
- Children
- \XmlPropertyTask
- Author
- Andreas Aderhold
- Author
- Hans Lellelid
- Copyright
- 2001,2002 THYRELL. All rights reserved
- Version
- $Id: e6d7123b6331d5032ad1e67967cf54ef2aae3f7f $
Properties

$override= 'false'
Whether to force overwrite of existing property.
falseDetails- Type
- n/a

\Project
$project= 'null'
Holds a reference to the project that a project component (a task, a target, etc.) belongs to
A reference to the current project instanceInherited from: \ProjectComponent::$$project\Task::$$projectnullDetails- Type
- \Project
- Inherited_from
- \ProjectComponent::$$project
- Inherited_from
- \Task::$$project

$userProperty= 'false'
Whether property should be treated as "user" property.
falseDetails- Type
- n/a
Methods

addProperties(
$props
)
:
voiditerate through a set of properties, resolve them then assign them
| Name | Type | Description |
|---|---|---|
| $props |

addProperty(
string $name, string $value
)
:
voidadd a name value pair to the project property set
| Name | Type | Description |
|---|---|---|
| $name | string | name of property |
| $value | string | value to set |

addText(
$value
)
:
voidSets value of property to CDATA tag contents.
| Name | Type | Description |
|---|---|---|
| $value |
- Since
- 2.2.0

getLocation(
)
:
\LocationReturns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.
Inherited from: \Task::getLocation()| Type | Description |
|---|---|
| \Location | The location object describing the position of this task within the buildfile. |

getProject(
)
:
\ProjectReturns a reference to current project
Inherited from: \ProjectComponent::getProject()\Task::getProject()| Type | Description |
|---|---|
| \Project | Reference to current porject object |

getRuntimeConfigurableWrapper(
)
:
\RuntimeConfigurableReturns the wrapper object for runtime configuration
Inherited from: \Task::getRuntimeConfigurableWrapper()| Type | Description |
|---|---|
| \RuntimeConfigurable | The wrapper object used by this task |

getTaskType(
)
:
stringReturns the name of the task under which it was invoked, usually the XML tagname
Inherited from: \Task::getTaskType()| Type | Description |
|---|---|
| string | The type of this task (XML Tag) |

init(
)
:
void
Should throw a BuildException if something goes wrong with the build
This is abstract here, but may not be overloaded by subclasses.
| Exception | Description |
|---|---|
| \BuildException |

loadEnvironment(
string $prefix
)
:
voidload the environment values
| Name | Type | Description |
|---|---|---|
| $prefix | string | prefix to place before them |

loadFile(
\PhingFile $file
)
:
voidload properties from a file.
| Name | Type | Description |
|---|---|---|
| $file | \PhingFile |

log(
string $msg, integer $level
=
Project::MSG_INFO
)
:
void
| Name | Type | Description |
|---|---|---|
| $msg | string | The message to log |
| $level | integer | The priority of the message |
- See
- \BuildEvent
- See
- \BuildListener

main(
)
:
voidset the property in the project to the value.
if the task was give a file or env attribute here is where it is loaded

maybeConfigure(
)
:
voidConfigure this task if it hasn't been done already.
Inherited from: \Task::maybeConfigure()
parsePropertyString(
string $value, array $fragments, array $propertyRefs
)
:
voidThis method will parse a string containing ${value} style property values into two lists. The first list is a collection of text fragments, while the other is a set of string property names null entries in the first list indicate a property reference from the second list.
This is slower than regex, but useful for this class, which has to handle multiple parsing passes for properties.
| Name | Type | Description |
|---|---|---|
| $value | string | The string to be scanned for property references |
| $fragments | array | &$fragments The found fragments |
| $propertyRefs | array | &$propertyRefs The found refs |

resolveAllProperties(
\Properties $props
)
:
voidGiven a Properties object, this method goes through and resolves any references to properties within the object.
| Name | Type | Description |
|---|---|---|
| $props | \Properties | The collection of Properties that need to be resolved. |

setDescription(
string $desc
)
:
void
| Name | Type | Description |
|---|---|---|
| $desc | string | The text describing the task |

setEnvironment(
\env $env
)
:
voidthe prefix to use when retrieving environment variables.
Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".
<
p>
Note that if you supply a property name with a final
"." it will not be doubled. ie environment="myenv." will still
allow access of environment variables through "myenv.PATH" and
"myenv.TERM". This functionality is currently only implemented
on select platforms. Feel free to send patches to increase the number of platforms
this functionality is supported on ;).
Note also that properties are case sensitive, even if the
environment variables on your operating system are not, e.g. it
will be ${env.Path} not ${env.PATH} on Windows 2000.
| Name | Type | Description |
|---|---|---|
| $env | \env | prefix |

setFile(
$file
)
:
voidSet a file to use as the source for properties.
| Name | Type | Description |
|---|---|---|
| $file |

setLocation(
\Location $location
)
:
voidSets the location within the buildfile this task occurs. Called by the parser to set location information.
Inherited from: \Task::setLocation()| Name | Type | Description |
|---|---|---|
| $location | \Location | The location object describing the position of this task within the buildfile. |

setName(
$name
)
:
voidSets a the name of current property component
| Name | Type | Description |
|---|---|---|
| $name |

setOwningTarget(
\Target $target
)
:
void
| Name | Type | Description |
|---|---|---|
| $target | \Target | Reference to owning target |

setPrefix(
string $prefix
)
:
voidPrefix to apply to properties loaded using file.
A "." is appended to the prefix if not specified.
| Name | Type | Description |
|---|---|---|
| $prefix | string | prefix string |
- Since
- 2.0

setProject(
\Project $project
)
:
voidReferences the project to the current component.
Inherited from: \ProjectComponent::setProject()\Task::setProject()| Name | Type | Description |
|---|---|---|
| $project | \Project | The reference to the current project |

setRuntimeConfigurableWrapper(
\RuntimeConfigurable $wrapper
)
:
voidSets the wrapper object this task should use for runtime configurable elements.
Inherited from: \Task::setRuntimeConfigurableWrapper()| Name | Type | Description |
|---|---|---|
| $wrapper | \RuntimeConfigurable | The wrapper object this task should use |

setTaskName(
string $name
)
:
string
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| string | A string representing the name of this task for log |

setTaskType(
string $name
)
:
voidSets the type of the task. Usually this is the name of the XML tag
Inherited from: \Task::setTaskType()| Name | Type | Description |
|---|---|---|
| $name | string | The type of this task (XML Tag) |

setUserProperty(
boolean $v
)
:
voidSet whether this is a user property (ro).
This is deprecated in Ant 1.5, but the userProperty attribute of the class is still being set via constructor, so Phing will allow this method to function.
| Name | Type | Description |
|---|---|---|
| $v | boolean |

setValue(
mixed $value
)
:
voidSets a the value of current property component.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Value of name, all scalars allowed |