123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
-
- require_once 'phing/tasks/system/AdhocTask.php';
- class AdhocTaskdefTask extends AdhocTask
- {
-
- private $name;
-
-
-
- public function setName($name)
- {
- $this->name = $name;
- }
-
-
- public function main()
- {
- if ($this->name === null)
- {
- throw new BuildException("The name attribute is required for adhoc task definition.",$this->location);
- }
-
- $taskdefs = $this->getProject()->getTaskDefinitions();
-
- if (!isset($taskdefs[$this->name]))
- {
- $this->execute();
- $classes = $this->getNewClasses();
-
- if (count($classes) !== 1)
- {
- throw new BuildException("You must define one (and only one) class for AdhocTaskdefTask.");
- }
-
- $classname = array_shift($classes);
-
- $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);
- }
- }
- }
|