.
*/
require_once 'phing/tasks/system/AdhocTask.php';
/**
* A class for creating adhoc tasks in build file.
*
*
* bar = $bar;
* }
*
* function main() {
* $this->log("In FooTest: " . $this->bar);
* }
* }
*
* ]]>
*
*
*
*
* @author Hans Lellelid
* @version $Revision: 1.5 $
* @package phing.tasks.system
*/
class AdhocTaskdefTask extends AdhocTask {
/**
* The tag that refers to this task.
*/
private $name;
/**
* Set the tag that will represent this adhoc task/type.
* @param string $name
*/
public function setName($name) {
$this->name = $name;
}
/** Main entry point */
public function main() {
if ($this->name === null) {
throw new BuildException("The name attribute is required for adhoc task definition.",$this->location);
}
$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);
// 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);
}
}