Project

The Phing project class. Represents a completely configured Phing project.

The class defines the project and all tasks/targets. It also contains methods to start a build as well as some properties and FileSystem abstraction.

author

Andreas Aderhold andi@binarycloud.com

author

Hans Lellelid hans@xmpl.org

version

$Id: ff8d17e05a829278cbc3db6d7e6d1509ab0c66b5 $

package

phing

Methods

Constructor, sets any default vars.

__construct() 

_makeCircularException

_makeCircularException( $end,  $stk) 

Arguments

$end

$stk

Topologically sort a set of Targets.

_topoSort(string $root, array &$targets) : \An

Arguments

$root

string

is the (String) name of the root Target. The sort is

    created in such a way that the sequence of Targets until the root
    target is the minimum possible such sequence.

$targets

array

is a array representing a "name to Target" mapping

Response

\An

array of Strings with the names of the targets in

    sorted order.

_tsort

_tsort( $root,  &$targets,  &$state,  &$visiting,  &$ret) 

Arguments

$root

$targets

$state

$visiting

$ret

addBuildListener

addBuildListener(\BuildListener $listener) 

Arguments

$listener

\BuildListener

Adds a data type definition.

addDataTypeDefinition(string $typeName, string $typeClass, string $classpath = null) 

Arguments

$typeName

string

Name of the type.

$typeClass

string

The class to use.

$classpath

string

The classpath to use.

Adds or replaces a target in the project

addOrReplaceTarget(string $targetName, \Target &$target) 

Arguments

$targetName

string

$target

\Target

Adds a reference to an object. This method is called when the parser detects a id="foo" attribute. It passes the id as $name and a reference to the object assigned to this id as $value

addReference(string $name, object $object) 

Arguments

$name

string

$object

object

Add a new target to the project

addTarget(string $targetName, \Target $target) 

Arguments

$targetName

string

$target

\Target

Adds a task definition.

addTaskDefinition(string $name, string $class, string $classpath = null) 

Arguments

$name

string

Name of tag.

$class

string

The class path to use.

$classpath

string

The classpat to use.

Copies all user properties that have not been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

copyInheritedProperties(\Project $other) 

To copy all "user" properties, you will also have to call \#copyUserProperties.

since

phing 2.0

Arguments

$other

\Project

the project to copy the properties to. Must not be null.

Copies all user properties that have been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

copyUserProperties(\Project $other) : void

To copy all "user" properties, you will also have to call \#copyInheritedProperties.

since

phing 2.0

Arguments

$other

\Project

the project to copy the properties to. Must not be null.

Creates a new condition and returns the reference to it

createCondition(string $conditionType) : \Condition
throws

Arguments

$conditionType

string

Response

\Condition

Create a datatype instance and return reference to it See createTask() for explanation how this works

createDataType(string $typeName) : object
throws

Exception

Arguments

$typeName

string

Type name

Response

object

A datatype object

Create a new task instance and return reference to it. This method is sorta factory like. A _local_ instance is created and a reference returned to that instance. Usually PHP destroys local variables when the function call ends. But not if you return a reference to that variable.

createTask(string $taskType) : \Task

This is kinda error prone, because if no reference exists to the variable it is destroyed just like leaving the local scope with primitive vars. There's no central place where the instance is stored as in other OOP like languages.

[HL] Well, ZE2 is here now, and this is still working. We'll leave this alone unless there's any good reason not to.

throws

Exception

Arguments

$taskType

string

Task name

Response

\Task

A task object

Executes a target

executeTarget(string $targetName) : void
throws

Arguments

$targetName

string

Name of Target to execute

Executes a list of targets

executeTargets(array $targetNames) : void
throws

Arguments

$targetNames

array

List of target names to execute

fireBuildFinished

fireBuildFinished( $exception) 

Arguments

$exception

fireBuildStarted

fireBuildStarted() 

fireMessageLogged

fireMessageLogged( $object,  $message,  $priority) 

Arguments

$object

$message

$priority

fireMessageLoggedEvent

fireMessageLoggedEvent( $event,  $message,  $priority) 

Arguments

$event

$message

$priority

fireTargetFinished

fireTargetFinished( $target,  $exception) 

Arguments

$target

$exception

fireTargetStarted

fireTargetStarted( $target) 

Arguments

$target

fireTaskFinished

fireTaskFinished( $task,  $exception) 

Arguments

$task

$exception

fireTaskStarted

fireTaskStarted( $task) 

Arguments

$task

Returns the basedir of this project

getBasedir() : \PhingFile
access

public

throws
author

Andreas Aderhold, andi@binarycloud.com

Response

\PhingFile

Basedir PhingFile object

getBuildListeners

getBuildListeners() 

Returns the data type definitions

getDataTypeDefinitions() : array

Response

array

Returns default target

getDefaultTarget() : string

Response

string

return the description, null otherwise

getDescription() : string|null

Response

string|null

returns the global filterset (future use)

getGlobalFilterSet() 

Retrieves the current input handler.

getInputHandler() : \InputHandler

Response

\InputHandler

Returns the name of this project

getName() : string
access

public

author

Andreas Aderhold, andi@binarycloud.com

Response

string

projectname

Get the minimum required phing version

getPhingVersion() : string

Response

string

Returns a copy of the properties table.

getProperties() : array

Response

array

A hashtable containing all properties

    (including user properties).

Returns the value of a property, if it is set.

getProperty(string $name) : string

Arguments

$name

string

The name of the property.

        May be <code>null</code>, in which case
        the return value is also <code>null</code>.

Response

string

The property value, or null for no match

    or if a <code>null</code> name is provided.

Returns a specific reference.

getReference(string $key) : object

Arguments

$key

string

The reference id/key.

Response

object

Reference or null if not defined

Returns the references array.

getReferences() : array

Response

array

Returns the available targets

getTargets() : array

Response

array

Returns the task definitions

getTaskDefinitions() : array

Response

array

Returns a copy of the user property hashtable

getUserProperties() : \a

Response

\a

hashtable containing just the user properties

Returns the value of a user property, if it is set.

getUserProperty(string $name) : string

Arguments

$name

string

The name of the property.

        May be <code>null</code>, in which case
        the return value is also <code>null</code>.

Response

string

The property value, or null for no match

    or if a <code>null</code> name is provided.

inits the project, called from main app

init() 

Abstracting and simplifyling Logger calls for project messages

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

Arguments

$msg

string

$level

integer

logObject

logObject( $obj,  $msg,  $level) 

Arguments

$obj

$msg

$level

removeBuildListener

removeBuildListener(\BuildListener $listener) 

Arguments

$listener

\BuildListener

Replaces ${} style constructions in the given value with the string value of the corresponding data types.

replaceProperties( $value) : \the
exception

BuildException if the given value has an unclosed

                      property name, e.g. <code>${xxx</code>

Arguments

$value

Response

\the

given string with embedded property names replaced

    by values, or <code>null</code> if the given string is
    <code>null</code>.

Helper function

resolveFile( $fileName,  $rootDir = null) 

Arguments

$fileName

$rootDir

Set basedir object from xm

setBasedir(\PhingFile|string $dir) 

Arguments

$dir

\PhingFile|string

Sets default target

setDefaultTarget(string $targetName) 

Arguments

$targetName

string

Set the projects description

setDescription(string $description) 

Arguments

$description

string

Sets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten. Also marks these properties as properties that have not come from the command line.

setInheritedProperty(string $name, string $value) 
see \#setProperty()

Arguments

$name

string

The name of property to set.

        Must not be <code>null</code>.

$value

string

The new value of the property.

         Must not be <code>null</code>.

Sets the input handler

setInputHandler(\InputHandler $handler) 

Arguments

$handler

\InputHandler

Sets the name of the current project

setName(string $name) : void
access

public

author

Andreas Aderhold, andi@binarycloud.com

Arguments

$name

string

name of project

Sets a property if no value currently exists. If the property exists already, a message is logged and the method returns with no other effect.

setNewProperty(string $name, string $value) 
since 2.0

Arguments

$name

string

The name of property to set.

        Must not be <code>null</code>.

$value

string

The new value of the property.

         Must not be <code>null</code>.

Set the minimum required phing version

setPhingVersion(string $version) 

Arguments

$version

string

Sets a property. Any existing property of the same name is overwritten, unless it is a user property.

setProperty(string $name, string $value) : void

Arguments

$name

string

The name of property to set.

        Must not be <code>null</code>.

$value

string

The new value of the property.

         Must not be <code>null</code>.

Sets a property unless it is already defined as a user property (in which case the method returns silently).

setPropertyInternal( $name,  $value) 

Arguments

$name

$value

Sets system properties and the environment variables for this project.

setSystemProperties() : void

Sets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten.

setUserProperty(string $name, string $value) 
see \#setProperty()

Arguments

$name

string

The name of property to set.

        Must not be <code>null</code>.

$value

string

The new value of the property.

         Must not be <code>null</code>.

Constants

MSG_DEBUG

MSG_DEBUG

MSG_VERBOSE

MSG_VERBOSE

MSG_INFO

MSG_INFO

MSG_WARN

MSG_WARN

MSG_ERR

MSG_ERR

Properties

contains the targets

targets : 

Type(s)

global filterset (future use)

globalFilterSet : 

Type(s)

all globals filters (future use)

globalFilters : 

Type(s)

Project properties map (usually String to String).

properties : 

Type(s)

Map of "user" properties (as created in the Ant task, for example).

userProperties : 

Note that these key/value pairs are also always put into the project properties, so only the project properties need to be queried. Mapping is String to String.

Type(s)

Map of inherited "user" properties - that are those "user" properties that have been created by tasks and not been set from the command line or a GUI tool.

inheritedProperties : 

Mapping is String to String.

Type(s)

task definitions for this project

taskdefs : 

Type(s)

type definitions for this project

typedefs : 

Type(s)

holds ref names and a reference to the referred object

references : 

Type(s)

The InputHandler being used by this project.

inputHandler : 

Type(s)

basedir (PhingFile object)

basedir : 

Type(s)

the default target name

defaultTarget : 

Type(s)

project name (required)

name : 

Type(s)

project description

description : 

Type(s)

require phing version

phingVersion : 

Type(s)

a FileUtils object

fileUtils : 

Type(s)

Build listeneers

listeners : 

Type(s)