Executes a command on the shell.

Use Project#createTask to register a new Task.

author Andreas Aderhold
author Hans Lellelid
author Christian Weiske
version $Id: 2690e22f87a077341ba91b2c1908f85a635d7b21 $
package phing.tasks.system
copyright 2001,2002 THYRELL. All rights reserved

 Methods

__construct()

__construct() 

Creates a nested <arg> tag.

createArg() : \CommandlineArgument

Returns

\CommandlineArgumentArgument object

Returns the textual description of the task

getDescription() : string
Inherited
inherited_from \Task::getDescription()

Returns

stringThe text description of the task

Returns the location within the buildfile this task occurs.

getLocation() : \Location
Inherited

Used by BuildException to give detailed error messages.

inherited_from \Task::getLocation()

Returns

\LocationThe location object describing the position of this task within the buildfile.

Returns the owning target of this task.

getOwningTarget() : \Target
Inherited
inherited_from \Task::getOwningTarget()

Returns

\TargetThe target object that owns this task

Returns a reference to current project

getProject() : \Project
Inherited
inherited_from \ProjectComponent::getProject()
inherited_from \Task::getProject()

Returns

\ProjectReference to current porject object

Returns the wrapper object for runtime configuration

getRuntimeConfigurableWrapper() : \RuntimeConfigurable
Inherited
inherited_from \Task::getRuntimeConfigurableWrapper()

Returns

\RuntimeConfigurableThe wrapper object used by this task

Returns the name of task, used only for log messages

getTaskName() : string
Inherited
inherited_from \Task::getTaskName()

Returns

stringName of this task

Returns the name of the task under which it was invoked, usually the XML tagname

getTaskType() : string
Inherited
inherited_from \Task::getTaskType()

Returns

stringThe type of this task (XML Tag)

Called by the parser to let the task initialize properly.

init() 
Inherited

Should throw a BuildException if something goes wrong with the build

This is abstract here, but may not be overloaded by subclasses.

inherited_from \Task::init()

Exceptions

\BuildException

Provides a project level log event to the task.

log(string $msg, integer $level) 
Inherited
see \global\BuildEvent
see \global\BuildListener
inherited_from \Task::log()

Parameters

$msg

string

The message to log

$level

integer

The priority of the message

Main method: wraps execute() command.

main() : void

This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running phing target1 target2 will run all tasks in target3 twice.

Should throw a BuildException if someting goes wrong with the build

This is abstract here. Must be overloaded by real tasks.

Configure this task if it hasn't been done already.

maybeConfigure() 
Inherited
inherited_from \Task::maybeConfigure()

Perfrom this task

perform() 
Inherited
inherited_from \Task::perform()

Whether to check the return code.

setCheckreturn(boolean $checkreturn) : void

Parameters

$checkreturn

boolean

If the return code shall be checked

The command to use.

setCommand(mixed $command) : void

Parameters

$command

mixed

String or string-compatible (e.g. w/ __toString()).

Sets a textual description of the task

setDescription(string $desc) 
Inherited
inherited_from \Task::setDescription()

Parameters

$desc

string

The text describing the task

Specify the working directory for executing this command.

setDir(\PhingFile $dir) : void

Parameters

$dir

\PhingFile

Working directory

File to which error output should be written.

setError(\PhingFile $f) : void

Parameters

$f

\PhingFile

Error log file

Whether to use escapeshellcmd() to escape command.

setEscape(boolean $escape) : void

Parameters

$escape

boolean

If the command shall be escaped or not

The executable to use.

setExecutable(mixed $executable) : void

Parameters

$executable

mixed

String or string-compatible (e.g. w/ __toString()).

Set level of log messages generated (default = verbose)

setLevel(string $level) : void

Parameters

$level

string

Log level

Sets the location within the buildfile this task occurs.

setLocation(\Location $location) 
Inherited

Called by the parser to set location information.

inherited_from \Task::setLocation()

Parameters

$location

\Location

The location object describing the position of this task within the buildfile.

Whether to log returned output as MSG_INFO instead of MSG_VERBOSE

setLogoutput(boolean $logOutput) : void

Parameters

$logOutput

boolean

If output shall be logged visibly

Specify OS (or muliple OS) that must match in order to execute this command.

setOs(string $os) : void

Parameters

$os

string

Operating system string (e.g. "Linux")

File to which output should be written.

setOutput(\PhingFile $f) : void

Parameters

$f

\PhingFile

Output log file

The name of property to set to output value from exec() call.

setOutputProperty(string $prop) : void

Parameters

$prop

string

Property name

Sets the owning target this task belongs to.

setOwningTarget(\Target $target) 
Inherited
inherited_from \Task::setOwningTarget()

Parameters

$target

\Target

Reference to owning target

Whether to use PHP's passthru() function instead of exec()

setPassthru(boolean $passthru) : void

Parameters

$passthru

boolean

If passthru shall be used

References the project to the current component.

setProject(\Project $project) 
Inherited
inherited_from \ProjectComponent::setProject()
inherited_from \Task::setProject()

Parameters

$project

\Project

The reference to the current project

The name of property to set to return value from exec() call.

setReturnProperty(string $prop) : void

Parameters

$prop

string

Property name

Sets the wrapper object this task should use for runtime configurable elements.

setRuntimeConfigurableWrapper(\RuntimeConfigurable $wrapper) 
Inherited
inherited_from \Task::setRuntimeConfigurableWrapper()

Parameters

$wrapper

\RuntimeConfigurable

The wrapper object this task should use

Whether to suppress all output and run in the background.

setSpawn(boolean $spawn) : void

Parameters

$spawn

boolean

If the command is to be run in the background

Sets the name of this task for log messages

setTaskName(string $name) : string
Inherited
inherited_from \Task::setTaskName()

Parameters

$name

string

Returns

stringA string representing the name of this task for log

Sets the type of the task.

setTaskType(string $name) 
Inherited

Usually this is the name of the XML tag

inherited_from \Task::setTaskType()

Parameters

$name

string

The type of this task (XML Tag)

Builds the full command to execute and stores it in $command.

buildCommand() : void
uses \global\$command

Runs all tasks after command execution: - change working directory back - log output - verify return value

cleanup(integer $return, array $output) : void

Parameters

$return

integer

Return code

$output

array

Array with command output

Executes the command and returns return code and output.

executeCommand() : array

Returns

arrayarray(return code, array with output)

Returns a name

getRegisterSlot(string $slotName) 
Inherited
inherited_from \Task::getRegisterSlot()

Parameters

$slotName

string

Checks whether the command shall be executed

isApplicable() : boolean

Returns

booleanFalse if the exec command shall not be run

Prepares the command building and execution, i.e.

prepare() : void

changes to the specified directory.

 Properties

 

$checkreturn : boolean
 

$command : string
 

$commandline : \Commandline
 

$description : string
Inherited
inherited_from \Task::$$description
 

$dir : \PhingFile
 

$error : \File
 

$escape : boolean
 

$location : \Location
Inherited
inherited_from \Task::$$location
 

$logLevel : integer
 

$logOutput : boolean
 

$os : string
 

$output : \File
 

$outputProperty : string
 

$passthru : boolean
 

$project : \Project
Inherited
inherited_from \ProjectComponent::$$project
inherited_from \Task::$$project
 

$realCommand : string
 

$returnProperty : string
 

$spawn : boolean
 

$target : \Target
Inherited
inherited_from \Task::$$target
 

$taskName : string
Inherited
inherited_from \Task::$$taskName
 

$taskType : string
Inherited
inherited_from \Task::$$taskType
 

$wrapper : \RuntimeConfigurable
Inherited
inherited_from \Task::$$wrapper