/usr/share/php/phing/Task.php is in phing 2.8.2+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | <?php
/*
* $Id: 02ca39be55adc06cf8fd0fa4d3a6c6cc391ea604 $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
require_once 'phing/ProjectComponent.php';
include_once 'phing/RuntimeConfigurable.php';
/**
* The base class for all Tasks.
*
* Use {@link Project#createTask} to register a new Task.
*
* @author Andreas Aderhold <andi@binarycloud.com>
* @copyright 2001,2002 THYRELL. All rights reserved
* @version $Id: 02ca39be55adc06cf8fd0fa4d3a6c6cc391ea604 $
* @see Project#createTask()
* @package phing
*/
abstract class Task extends ProjectComponent {
/**
* Owning Target object
* @var Target
*/
protected $target;
/**
* Description of the task
* @var string
*/
protected $description;
/**
* Internal taskname (req)
* @var string
*/
protected $taskType;
/**
* Taskname for logger
* @var string
*/
protected $taskName;
/**
* Stored buildfile location
* @var Location
*/
protected $location;
/**
* Wrapper of the task
* @var RuntimeConfigurable
*/
protected $wrapper;
/**
* Sets the owning target this task belongs to.
*
* @param Target Reference to owning target
*/
public function setOwningTarget(Target $target) {
$this->target = $target;
}
/**
* Returns the owning target of this task.
*
* @return Target The target object that owns this task
*/
public function getOwningTarget() {
return $this->target;
}
/**
* Returns the name of task, used only for log messages
*
* @return string Name of this task
*/
public function getTaskName() {
if ($this->taskName === null) {
// if no task name is set, then it's possible
// this task was created from within another task. We don't
// therefore know the XML tag name for this task, so we'll just
// use the class name stripped of "task" suffix. This is only
// for log messages, so we don't have to worry much about accuracy.
return preg_replace('/task$/i', '', get_class($this));
}
return $this->taskName;
}
/**
* Sets the name of this task for log messages
*
* @param string $name
* @return string A string representing the name of this task for log
*/
public function setTaskName($name) {
$this->taskName = (string) $name;
}
/**
* Returns the name of the task under which it was invoked,
* usually the XML tagname
*
* @return string The type of this task (XML Tag)
*/
public function getTaskType() {
return $this->taskType;
}
/**
* Sets the type of the task. Usually this is the name of the XML tag
*
* @param string The type of this task (XML Tag)
*/
public function setTaskType($name) {
$this->taskType = (string) $name;
}
/**
* Returns a name
* @param string $slotName
*/
protected function getRegisterSlot($slotName) {
return Register::getSlot('task.' . $this->getTaskName() . '.' . $slotName);
}
/**
* Provides a project level log event to the task.
*
* @param string The message to log
* @param integer The priority of the message
* @see BuildEvent
* @see BuildListener
*/
function log($msg, $level = Project::MSG_INFO) {
$this->project->logObject($this, $msg, $level);
}
/**
* Sets a textual description of the task
*
* @param string $desc The text describing the task
*/
public function setDescription($desc) {
$this->description = $desc;
}
/**
* Returns the textual description of the task
*
* @return string The text description of the task
*/
public function getDescription() {
return $this->description;
}
/**
* Called by the parser to let the task initialize properly.
* Should throw a BuildException if something goes wrong with the build
*
* This is abstract here, but may not be overloaded by subclasses.
*
* @throws BuildException
*/
public function init() {
}
/**
* Called by the project to let the task do it's work. This method may be
* called more than once, if the task is invoked more than once. For
* example, if target1 and target2 both depend on target3, then running
* <em>phing target1 target2</em> will run all tasks in target3 twice.
*
* Should throw a BuildException if someting goes wrong with the build
*
* This is abstract here. Must be overloaded by real tasks.
*/
abstract public function main();
/**
* Returns the location within the buildfile this task occurs. Used
* by {@link BuildException} to give detailed error messages.
*
* @return Location The location object describing the position of this
* task within the buildfile.
*/
function getLocation() {
return $this->location;
}
/**
* Sets the location within the buildfile this task occurs. Called by
* the parser to set location information.
*
* @param Location $location The location object describing the position of this
* task within the buildfile.
*/
function setLocation(Location $location) {
$this->location = $location;
}
/**
* Returns the wrapper object for runtime configuration
*
* @return RuntimeConfigurable The wrapper object used by this task
*/
function getRuntimeConfigurableWrapper() {
if ($this->wrapper === null) {
$this->wrapper = new RuntimeConfigurable($this, $this->getTaskName());
}
return $this->wrapper;
}
/**
* Sets the wrapper object this task should use for runtime
* configurable elements.
*
* @param RuntimeConfigurable $wrapper The wrapper object this task should use
*/
function setRuntimeConfigurableWrapper(RuntimeConfigurable $wrapper) {
$this->wrapper = $wrapper;
}
/**
* Configure this task if it hasn't been done already.
*/
public function maybeConfigure() {
if ($this->wrapper !== null) {
$this->wrapper->maybeConfigure($this->project);
}
}
/**
* Perfrom this task
*/
public function perform() {
try { // try executing task
$this->project->fireTaskStarted($this);
$this->maybeConfigure();
$this->main();
$this->project->fireTaskFinished($this, $null=null);
} catch (Exception $exc) {
if ($exc instanceof BuildException) {
if ($this->getLocation() !== null) {
$exc->setLocation($this->getLocation());
}
}
$this->project->fireTaskFinished($this, $exc);
throw $exc;
}
}
}
|