diff options
Diffstat (limited to 'buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php')
-rwxr-xr-x[-rw-r--r--] | buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php b/buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php index ea336f84..03f80b27 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: AdhocTaskdefTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: da14cd0fdc73a0eb13ecc8c0b5ae693550a052b1 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -46,10 +46,11 @@ require_once 'phing/tasks/system/AdhocTask.php'; * </target> * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.5 $ + * @version $Id$ * @package phing.tasks.system */ -class AdhocTaskdefTask extends AdhocTask { +class AdhocTaskdefTask extends AdhocTask +{ /** * The tag that refers to this task. @@ -60,31 +61,43 @@ class AdhocTaskdefTask extends AdhocTask { * Set the tag that will represent this adhoc task/type. * @param string $name */ - public function setName($name) { + public function setName($name) + { $this->name = $name; } /** Main entry point */ - public function main() { - if ($this->name === null) { + public function main() + { + if ($this->name === null) + { throw new BuildException("The name attribute is required for adhoc task definition.",$this->location); } - $this->execute(); + $taskdefs = $this->getProject()->getTaskDefinitions(); - $classes = $this->getNewClasses(); - if (count($classes) !== 1) { - throw new BuildException("You must define one (and only one) class for AdhocTaskdefTask."); - } - $classname = array_shift($classes); - - // instantiate it to make sure it is an instance of Task - $t = new $classname(); - if (!($t instanceof Task)) { - throw new BuildException("The adhoc class you defined must be an instance of phing.Task", $this->location); + if (!isset($taskdefs[$this->name])) + { + $this->execute(); + + $classes = $this->getNewClasses(); + + if (count($classes) < 1) + { + throw new BuildException("You must define at least one class for AdhocTaskdefTask."); + } + + $classname = array_pop($classes); + + // instantiate it to make sure it is an instance of Task + $t = new $classname(); + if (!($t instanceof Task)) + { + throw new BuildException("The adhoc class you defined must be an instance of phing.Task", $this->location); + } + + $this->log("Task " . $this->name . " will be handled by class " . $classname, Project::MSG_VERBOSE); + $this->project->addTaskDefinition($this->name, $classname); } - - $this->log("Task " . $this->name . " will be handled by class " . $classname, PROJECT_MSG_VERBOSE); - $this->project->addTaskDefinition($this->name, $classname); } } |