classes/phing/Project.php

\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
author
Hans Lellelid
package
phing
version
$Revision: 1097 $

Constants

Constant  MSG_DEBUG = '4'
Constant  MSG_VERBOSE = '3'
Constant  MSG_INFO = '2'
Constant  MSG_WARN = '1'
Constant  MSG_ERR = '0'

Properties

Propertyprivate  $basedir= ''

basedir (PhingFile object)

Details
Type
Propertyprivate  $defaultTarget= 'all'

the default target name

Default valueallDetails
Type
Propertyprivate  $description= ''

project description

Details
Type
Propertyprivate  $fileUtils= ''

a FileUtils object

Details
Type
Propertyprivate  $globalFilterSet= 'array'

global filterset (future use)

Default valuearrayDetails
Type
Propertyprivate  $globalFilters= 'array'

all globals filters (future use)

Default valuearrayDetails
Type
Propertyprivate  $inheritedProperties= 'array'

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.

Mapping is String to String.

Default valuearrayDetails
Type
Propertyprivate  $inputHandler= ''

The InputHandler being used by this project.

Details
Type
Propertyprivate  $listeners= 'array'

Build listeneers

Default valuearrayDetails
Type
Propertyprivate  $name= ''

project name (required)

Details
Type
Propertyprivate  $phingVersion= ''

require phing version

Details
Type
Propertyprivate  $properties= 'array'

Project properties map (usually String to String).

Default valuearrayDetails
Type
Propertyprivate  $references= 'array'

holds ref names and a reference to the referred object

Default valuearrayDetails
Type
Propertyprivate  $targets= 'array'

contains the targets

Default valuearrayDetails
Type
Propertyprivate  $taskdefs= 'array'

task definitions for this project

Default valuearrayDetails
Type
Propertyprivate  $typedefs= 'array'

type definitions for this project

Default valuearrayDetails
Type
Propertyprivate  $userProperties= 'array'

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

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.

Default valuearrayDetails
Type

Methods

methodpublic  __construct( ) :
Constructor, sets any default vars.
methodpublic  _makeCircularException(  $end,  $stk ) :
Parameters
Name Type Description
$end
$stk
methodpublic  _topoSort( \$root $root, \$targets $targets ) : \An
Topologically sort a set of Targets.
Parameters
Name Type Description
$root \$root

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 \$targets

is a array representing a "name to Target" mapping

Returns
Type Description
\An
methodpublic  _tsort(  $root,  $targets,  $state,  $visiting,  $ret ) :
Parameters
Name Type Description
$root
$targets
$state
$visiting
$ret
methodpublic  addBuildListener(  $listener ) :
Parameters
Name Type Description
$listener
methodpublic  addDataTypeDefinition(  $typeName,  $typeClass, string $classpath = null ) :
Adds a data type definition.
Parameters
Name Type Description
$typeName
$typeClass
$classpath string The classpat to use.
methodpublic  addOrReplaceTarget(  $targetName,  $target ) :
Parameters
Name Type Description
$targetName
$target
methodpublic  addReference(  $name,  $object ) :
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
Parameters
Name Type Description
$name
$object
methodpublic  addTarget(  $targetName,  $target ) :
add a new target to the project
Parameters
Name Type Description
$targetName
$target
methodpublic  addTaskDefinition( string $name, string $class, string $classpath = null ) :
Adds a task definition.
Parameters
Name Type Description
$name string Name of tag.
$class string The class path to use.
$classpath string The classpat to use.
methodpublic  copyInheritedProperties( \other $other ) :
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.

To copy all "user" properties, you will also have to call {@link #copyUserProperties copyUserProperties}.

Parameters
Name Type Description
$other \other the project to copy the properties to. Must not be null.
Details
since
phing 2.0
methodpublic  copyUserProperties( \Project $other ) : void
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.

To copy all "user" properties, you will also have to call {@link #copyInheritedProperties copyInheritedProperties}.

Parameters
Name Type Description
$other \Project the project to copy the properties to. Must not be null.
Details
since
phing 2.0
methodpublic  createDataType( string $typeName ) : object
Create a datatype instance and return reference to it See createTask() for explanation how this works
Parameters
Name Type Description
$typeName string Type name
Returns
Type Description
object
Details
throws
Exception
methodpublic  createTask( string $taskType ) : \Task
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.

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.

Parameters
Name Type Description
$taskType string Task name
Returns
Type Description
\Task
Details
throws
Exception
methodpublic  executeTarget( string $targetName ) : void
Executes a target
Parameters
Name Type Description
$targetName string Name of Target to execute
Details
throws
methodpublic  executeTargets( array $targetNames ) : void
Executes a list of targets
Parameters
Name Type Description
$targetNames array List of target names to execute
Details
throws
methodpublic  fireBuildFinished(  $exception ) :
Parameters
Name Type Description
$exception
methodpublic  fireBuildStarted( ) :
methodpublic  fireMessageLogged(  $object,  $message,  $priority ) :
Parameters
Name Type Description
$object
$message
$priority
methodpublic  fireMessageLoggedEvent(  $event,  $message,  $priority ) :
Parameters
Name Type Description
$event
$message
$priority
methodpublic  fireTargetFinished(  $target,  $exception ) :
Parameters
Name Type Description
$target
$exception
methodpublic  fireTargetStarted(  $target ) :
Parameters
Name Type Description
$target
methodpublic  fireTaskFinished(  $task,  $exception ) :
Parameters
Name Type Description
$task
$exception
methodpublic  fireTaskStarted(  $task ) :
Parameters
Name Type Description
$task
methodpublic  getBasedir( ) : \PhingFile
Returns the basedir of this project
Returns
Type Description
\PhingFile
Details
access
public
author
Andreas Aderhold, andi@binarycloud.com
throws
methodpublic  getBuildListeners( ) :
methodpublic  getDataTypeDefinitions( ) :
methodpublic  getDefaultTarget( ) :
methodpublic  getDescription( ) :
return the description, null otherwise
methodpublic  getGlobalFilterSet( ) :
returns the global filterset (future use)
methodpublic  getInputHandler( ) :
Retrieves the current input handler.
methodpublic  getName( ) : string
Returns the name of this project
Returns
Type Description
string
Details
access
public
author
Andreas Aderhold, andi@binarycloud.com
methodpublic  getPhingVersion( ) :
Get the minimum required phing version *
methodpublic  getProperties( ) : array
Returns a copy of the properties table.
Returns
Type Description
array
methodpublic  getProperty( string $name ) : string
Returns the value of a property, if it is set.
Parameters
Name Type Description
$name string

The name of the property. May be null, in which case the return value is also null.

Returns
Type Description
string
methodpublic  getReference( string $key ) : \Reference
Returns a specific reference.
Parameters
Name Type Description
$key string

The reference id/key.

Returns
Type Description
\Reference
methodpublic  getReferences( ) : array
Returns the references array.
Returns
Type Description
array
methodpublic  getTargets( ) :
methodpublic  getTaskDefinitions( ) :
methodpublic  getUserProperties( ) : \a
Returns a copy of the user property hashtable
Returns
Type Description
\a
methodpublic  getUserProperty( string $name ) : string
Returns the value of a user property, if it is set.
Parameters
Name Type Description
$name string

The name of the property. May be null, in which case the return value is also null.

Returns
Type Description
string
methodpublic  init( ) :
inits the project, called from main app
methodpublic  log(  $msg,  $level = Project ) :
Abstracting and simplifyling Logger calls for project messages
Parameters
Name Type Description
$msg
$level
methodpublic  logObject(  $obj,  $msg,  $level ) :
Parameters
Name Type Description
$obj
$msg
$level
methodpublic  removeBuildListener(  $listener ) :
Parameters
Name Type Description
$listener
methodpublic  replaceProperties( \value $value ) : \the
Replaces ${} style constructions in the given value with the string value of the corresponding data types.
Parameters
Name Type Description
$value \value

The string to be scanned for property references. May be null.

Returns
Type Description
\the
Details
exception
BuildException if the given value has an unclosed property name, e.g. ${xxx
methodpublic  resolveFile(  $fileName,  $rootDir = null ) :
Parameters
Name Type Description
$fileName
$rootDir
methodpublic  setBasedir(  $dir ) :
Set basedir object from xml
Parameters
Name Type Description
$dir
methodpublic  setDefaultTarget(  $targetName ) :
Parameters
Name Type Description
$targetName
methodpublic  setDescription(  $description ) :
Set the projects description
Parameters
Name Type Description
$description
methodpublic  setInheritedProperty( string $name, string $value ) :
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.
Parameters
Name Type Description
$name string

The name of property to set. Must not be null.

$value string

The new value of the property. Must not be null.

Details
see
\#setProperty()
methodpublic  setInputHandler(  $handler ) :
Sets the input handler
Parameters
Name Type Description
$handler
methodpublic  setName( string $name ) : void
Sets the name of the current project
Parameters
Name Type Description
$name string name of project
Details
access
public
author
Andreas Aderhold, andi@binarycloud.com
methodpublic  setNewProperty( string $name, string $value ) :
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.
Parameters
Name Type Description
$name string

The name of property to set. Must not be null.

$value string

The new value of the property. Must not be null.

Details
since
2.0
methodpublic  setPhingVersion(  $version ) :
Set the minimum required phing version *
Parameters
Name Type Description
$version
methodpublic  setProperty( string $name, string $value ) : void
Sets a property. Any existing property of the same name is overwritten, unless it is a user property.
Parameters
Name Type Description
$name string

The name of property to set. Must not be null.

$value string

The new value of the property. Must not be null.

methodprivate  setPropertyInternal( \name $name, \value $value ) :
Sets a property unless it is already defined as a user property (in which case the method returns silently).
Parameters
Name Type Description
$name \name

The name of the property. Must not be null.

$value \value

The property value. Must not be null.

methodpublic  setSystemProperties( ) : void
Sets system properties and the environment variables for this project.
methodpublic  setUserProperty( string $name, string $value ) :
Sets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten.
Parameters
Name Type Description
$name string

The name of property to set. Must not be null.

$value string

The new value of the property. Must not be null.

Details
see
\#setProperty()
Documentation was generated by DocBlox 0.13.1.