Executes a command on the (filtered) file list/set.

(Loosely based on the "Ant Apply" task - http://ant.apache.org/manual/Tasks/apply.html)

author Utsav Handa <handautsav at hotmail dot com>
package phing.tasks.system
todo Add support for mapper, targetfile expressions
copyright 2001,2002 THYRELL. All rights reserved
version $Id$

 Methods

Supports embedded <arg> element.

createArg() : void

Supports embedded <filelist> element.

createFileList() : \FileList

Returns

Nested creator, adds a set of files (nested <fileset> attribute).

createFileSet() : \FileSet

This is for when you don't care what order files get appended.

Returns

Supports embedded <srcfile> element.

createSrcfile() : void

Returns the textual description of the task

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

Returns

stringThe text description of the task

Prepares the filename per base directory and relative path information

getFilePath($filename, $basedir, $relative) : mixed

Parameters

$filename

$basedir

$relative

Returns

mixedprocessed filenames

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)

Class Initialization

init() : void

Should throw a BuildException if something goes wrong with the build

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

Exceptions

\BuildException

Provides a project level log event to the task.

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

Parameters

$msg

string

The message to log

$level

integer

The priority of the message

Do work

main() 

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.

Exceptions

\BuildException

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()

To add the source filename at the end of command of automatically

setAddsourcefile(Boolean $addsourcefile) : void

Parameters

$addsourcefile

Boolean

Identifier for adding source file at the end of command

File to which output should be written

setAppend($append) : void

Parameters

$append

setCheckreturn()

setCheckreturn($failonerror) 

Parameters

$failonerror

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 the command execution.

setDir(\PhingFile $dir) : void

Parameters

$dir

\PhingFile

Set the working directory as specified

File to which error output should be written

setError(\PhingFile $errorfile) : void

Parameters

$errorfile

\PhingFile

Error log file

Escape command using 'escapeshellcmd' before execution

setEscape(boolean $escape) : void

Parameters

$escape

boolean

Escape command before execution

Sets the command executable information

setExecutable(string $executable) : void

Parameters

$executable

string

Executable path

Fail on command exits with a returncode other than zero

setFailonerror(boolean $failonerror) : void

Parameters

$failonerror

boolean

Indicator to fail on error

Whether to use forward-slash as file-separator on the file names

setForwardslash(boolean $forwardslash) : void

Parameters

$forwardslash

boolean

Indicator to use forward-slash

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.

Limit the amount of parallelism by passing at most this many sourcefiles at once

setMaxparallel($max) : void

Parameters

$max

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 $outputfile) : void

Parameters

$outputfile

\PhingFile

Output log file

The name of property to set to output value

setOutputProperty(string $propertyname) : void

Parameters

$propertyname

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

Run the command only once, appending all files as arguments

setParallel(Boolean $parallel) : void

Parameters

$parallel

Boolean

Identifier for files as arguments appending

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

Whether the filenames should be passed on the command line as relative pathnames (relative to the base directory of the corresponding fileset/list)

setRelative($relative) : void

Parameters

$relative

The name of property to set to return value

setReturnProperty(string $propertyname) : void

Parameters

$propertyname

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 spawn the command and run as background process

setSpawn(boolean $spawn) : void

Parameters

$spawn

boolean

If the command is to be run as a background process

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)

Returns a name

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

Parameters

$slotName

string

Checks whether the current O.S.

validateOS() : boolean

should be supported

Returns

booleanFalse if the exec command shall not be run

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

buildCommand() : void

Runs cleanup tasks post execution - Restore working directory

cleanup() : void

Executes the specified command and returns the return code & output.

executeCommand($command) : array

Parameters

$command

Returns

arrayarray(return code, array with output)

Initializes the task operations, i.e.

initialize() : void
  • Required information validation
  • Working directory

Processes the files list with provided information for execution

process($files, \#basedir $basedir) : void

Parameters

$files

File list for processing

$basedir

\#basedir

Base directory of the file list

Throws the exception with specified information

throwBuildException($information) : void

Parameters

$information

Exception information

 Properties

 

$addsourcefile : boolean
 

$appendoutput : boolean
 

$commandline : \commandline
 

$currentdirectory 
 

$currentos 
 

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

$dir : \phingfile
 

$error : \phingfile
 

$escape : boolean
 

$failonerror : boolean
 

$filelists 
 

$filesets : array
 

$forwardslash : boolean
 

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

$loglevel : integer
 

$maxparallel : integer
 

$os : string
 

$osvariant 
 

$output : \phingfile
 

$outputProperty : string
 

$parallel : boolean
 

$passthru : boolean
 

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

$realCommand : string
 

$relative : boolean
 

$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

 Constants

 

SOURCEFILE_ID

SOURCEFILE_ID