# ApplyTask

Extends \Task

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
package | phing.tasks.system
todo | Add support for mapper, targetfile expressions

### Methods

## Nested adder, adds a set of files (nested fileset attribute).

    addFileSet(\FileSet $fs) : void

### Arguments

#### $fs

`\FileSet`

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

    buildCommand() : void

## Runs cleanup tasks post execution - Restore working directory

    cleanup() : void

## Supports embedded <arg> element.

    createArg() : \CommandlineArgument

### Response

`\CommandlineArgument`

## Supports embedded <filelist> element.

    createFileList() : \FileList

### Response

`\FileList`

## Supports embedded <srcfile> element.

    createSrcfile() : void

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

    executeCommand(string $command) : array

### Arguments

#### $command

`string`

### Response

`array`

array(return code, array with output)

## Returns the textual description of the task

    getDescription() : string

inherited

### Response

`string`

The text description of the task

## Prepares the filename per base directory and relative path information

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

### Arguments

#### $filename

``

#### $basedir

``

#### $relative

``

### Response

`mixed`

processed filenames

## Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.

    getLocation() : \Location

inherited

### Response

`\Location`

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

## Returns the owning target of this task.

    getOwningTarget() : \Target

inherited

### Response

`\Target`

The target object that owns this task

## Returns a reference to current project

    getProject() : \Project

inherited

### Response

`\Project`

Reference to current porject object

## Returns a name

    getRegisterSlot(string $slotName) : \RegisterSlot

inherited

### Arguments

#### $slotName

`string`

### Response

`\RegisterSlot`

## Returns the wrapper object for runtime configuration

    getRuntimeConfigurableWrapper() : \RuntimeConfigurable

inherited

### Response

`\RuntimeConfigurable`

The wrapper object used by this task

## Returns the name of task, used only for log messages

    getTaskName() : string

inherited

### Response

`string`

Name of this task

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

    getTaskType() : string

inherited

### Response

`string`

The 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.

throws |

## Initializes the task operations, i.e.

    initialize() : void

- Required information validation
- Working directory

## Logs a message with the given priority.

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

inherited

### Arguments

#### $msg

`string`

The message to be logged.

#### $level

`integer`

The message's priority at this message should have

## Called by the project to let the task do it's work. 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 <em>phing target1 target2</em> will run all tasks in target3 twice.

    main()

inherited abstract

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

## Perfrom this task

    perform()

inherited

throws |

## Processes the files list with provided information for execution

    process(array $files, string $basedir) : void

### Arguments

#### $files

`array`

File list for processing

#### $basedir

`string`

Base directory of the file list

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

    setAddsourcefile(Boolean $addsourcefile) : void

### Arguments

#### $addsourcefile

`Boolean`

Identifier for adding source file at the end of command

## setCheckreturn

    setCheckreturn( $failonerror)

### Arguments

#### $failonerror

``

## Sets a textual description of the task

    setDescription(string $desc)

inherited

### Arguments

#### $desc

`string`

The text describing the task

## Specify the working directory for the command execution.

    setDir(\PhingFile $dir) : void

### Arguments

#### $dir

`\PhingFile`

Set the working directory as specified

## File to which error output should be written

    setError(\PhingFile $errorfile) : void

### Arguments

#### $errorfile

`\PhingFile`

Error log file

## Escape command using 'escapeshellcmd' before execution

    setEscape(boolean $escape) : void

### Arguments

#### $escape

`boolean`

Escape command before execution

## Sets the command executable information

    setExecutable(string $executable) : void

### Arguments

#### $executable

`string`

Executable path

## Fail on command exits with a returncode other than zero

    setFailonerror(boolean $failonerror) : void

### Arguments

#### $failonerror

`boolean`

Indicator to fail on error

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

    setForwardslash(boolean $forwardslash) : void

### Arguments

#### $forwardslash

`boolean`

Indicator to use forward-slash

## Sets the location within the buildfile this task occurs. Called by the parser to set location information.

    setLocation(\Location $location)

inherited

### Arguments

#### $location

`\Location`

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

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

    setOs(string $os) : void

### Arguments

#### $os

`string`

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

## File to which output should be written

    setOutput(\PhingFile $outputfile) : void

### Arguments

#### $outputfile

`\PhingFile`

Output log file

## The name of property to set to output value

    setOutputProperty(string $propertyname) : void

### Arguments

#### $propertyname

`string`

Property name

## Sets the owning target this task belongs to.

    setOwningTarget(\Target $target)

inherited

### Arguments

#### $target

`\Target`

## Run the command only once, appending all files as arguments

    setParallel(Boolean $parallel) : void

### Arguments

#### $parallel

`Boolean`

Identifier for files as arguments appending

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

    setPassthru(boolean $passthru) : void

### Arguments

#### $passthru

`boolean`

If passthru shall be used

## References the project to the current component.

    setProject(\Project $project) : void

inherited

### Arguments

#### $project

`\Project`

The reference to the current project

## The name of property to set to return value

    setReturnProperty(string $propertyname) : void

### Arguments

#### $propertyname

`string`

Property name

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

    setRuntimeConfigurableWrapper(\RuntimeConfigurable $wrapper)

inherited

### Arguments

#### $wrapper

`\RuntimeConfigurable`

The wrapper object this task should use

## Whether to spawn the command and run as background process

    setSpawn(boolean $spawn) : void

### Arguments

#### $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

### Arguments

#### $name

`string`

### Response

`string`

A string representing the name of this task for log

## Sets the type of the task. Usually this is the name of the XML tag

    setTaskType( $name)

inherited

### Arguments

#### $name

``

## Throws the exception with specified information

    throwBuildException( $information) : void

throws |

### Arguments

#### $information

``

Exception information

## Checks whether the current O.S. should be supported

    validateOS() : boolean

### Response

`boolean`

False if the exec command shall not be run

### Constants

## SOURCEFILE_ID

    SOURCEFILE_ID

### Properties

## File Set/List of files.

    filesets : array

var |

### Type(s)

`array`

## filelists

    filelists :

### Type(s)

``

## Commandline managing object

    commandline : \commandline

var |

### Type(s)

`\commandline`

## Working directory

    dir : \phingfile

var |

### Type(s)

`\phingfile`

## currentdirectory

    currentdirectory :

### Type(s)

``

## Command to be executed

    realCommand : string

var |

### Type(s)

`string`

## Escape (shell) command using 'escapeshellcmd' before execution

    escape : boolean

var |

### Type(s)

`boolean`

## Where to direct output

    output : \phingfile

var |

### Type(s)

`\phingfile`

## Where to direct error

    error : \phingfile

var |

### Type(s)

`\phingfile`

## Whether output should be appended to or overwrite an existing file

    appendoutput : boolean

var |

### Type(s)

`boolean`

## Runs the command only once, appending all files as arguments else command will be executed once for every file.

    parallel : boolean

var |

### Type(s)

`boolean`

## Whether source file name should be added to the end of command automatically

    addsourcefile : boolean

var |

### Type(s)

`boolean`

## Whether to spawn the command execution as a background process

    spawn : boolean

var |

### Type(s)

`boolean`

## Property name to set with return value

    returnProperty : string

var |

### Type(s)

`string`

## Property name to set with output value

    outputProperty : string

var |

### Type(s)

`string`

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

    relative : boolean

var |

### Type(s)

`boolean`

## Operating system information

    os : string

var |

### Type(s)

`string`

## currentos

    currentos :

### Type(s)

``

## osvariant

    osvariant :

### Type(s)

``

## Logging level for status messages

    loglevel : integer

var |

### Type(s)

`integer`

## Fail on command that exits with a returncode other than zero

    failonerror : boolean

var |

### Type(s)

`boolean`

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

    passthru : boolean

var |

### Type(s)

`boolean`

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

    forwardslash : boolean

var |

### Type(s)

`boolean`

## Limit the amount of parallelism by passing at most this many sourcefiles at once (Set it to <= 0 for unlimited)

    maxparallel : integer

var |

### Type(s)

`integer`

## Owning Target object

    target : \Target

inherited

var |

### Type(s)

`\Target`

## Description of the task

    description : string

inherited

var |

### Type(s)

`string`

## Internal taskname (req)

    taskType : string

inherited

var |

### Type(s)

`string`

## Taskname for logger

    taskName : string

inherited

var |

### Type(s)

`string`

## Stored buildfile location

    location : \Location

inherited

var |

### Type(s)

`\Location`

## Wrapper of the task

    wrapper : \RuntimeConfigurable

inherited

var |

### Type(s)

`\RuntimeConfigurable`

## 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`