Changeset 367
- Timestamp:
- 05/18/08 17:14:13 (8 months ago)
- Files:
-
- branches/2.4/classes/phing/tasks/system/TaskdefTask.php (modified) (3 diffs)
- branches/2.4/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html (modified) (3 diffs)
- branches/2.4/test/classes/example/tasks/TaskdefTestSimpleTask.php (modified) (1 diff)
- branches/2.4/test/classes/phing/tasks/TaskdefTaskTest.php (added)
- branches/2.4/test/etc/tasks/taskdef.properties (added)
- branches/2.4/test/etc/tasks/taskdef.xml (added)
- branches/2.4/test/run-tests.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.4/classes/phing/tasks/system/TaskdefTask.php
r144 r367 22 22 23 23 require_once 'phing/Task.php'; 24 include_once 'phing/system/io/PhingFile.php'; 24 25 25 26 /** … … 69 70 */ 70 71 private $classpathId; 72 73 /** 74 * Name of file to load multiple definitions from. 75 * @var string 76 */ 77 private $typeFile; 71 78 72 79 /** … … 117 124 } 118 125 126 /** 127 * Sets the file of definitionas to use to use. 128 * @param string $file 129 */ 130 public function setFile($file) { 131 $this->typeFile = $file; 132 } 133 119 134 /** Main entry point */ 120 135 public function main() { 121 if ($this->name === null || $this->classname === null) { 136 if ($this->typeFile === null && 137 ($this->name === null || $this->classname === null)) { 122 138 throw new BuildException("You must specify name and class attributes for <taskdef>."); 123 139 } 124 $this->log("Task " . $this->name . " will be handled by class " . $this->classname, Project::MSG_VERBOSE); 125 $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); 140 if ($this->typeFile == null) { 141 $this->log("Task " . $this->name . " will be handled by class " . $this->classname, Project::MSG_VERBOSE); 142 $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); 143 } else { 144 try { // try to load taskdefs given in file 145 $props = new Properties(); 146 $in = new PhingFile((string) $this->typeFile); 147 148 if ($in === null) { 149 throw new BuildException("Can't load task list {$this->typeFile}"); 150 } 151 $props->load($in); 152 153 $enum = $props->propertyNames(); 154 foreach($enum as $key) { 155 $value = $props->getProperty($key); 156 $this->project->addTaskDefinition($key, $value, $this->classpath); 157 } 158 } catch (IOException $ioe) { 159 throw new BuildException("Can't load task list {$this->typeFile}"); 160 } 161 } 126 162 } 127 163 } branches/2.4/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html
r360 r367 1491 1491 the $PHP_CLASSPATH --> 1492 1492 <taskdef classname="user.sometasks.RebootTask" name="reboot" /> 1493 1494 <!-- Includes all tasks from the property file. Each line in the property 1495 file defines a task in the format: name=path.to.Task --> 1496 <taskdef file="/path/to/mytasks.properties" /> 1497 1493 1498 </pre> 1494 1499 <h3>Attributes</h3> … … 1511 1516 </td> 1512 1517 <td>n/a</td> 1513 <td>Yes </td>1518 <td>Yes, unless the <code>file</code> attribute has been specified.</td> 1514 1519 </tr> 1515 1520 <tr> … … 1522 1527 </td> 1523 1528 <td>n/a</td> 1524 <td>Yes</td> 1529 <td>Yes, unless the <code>file</code> attribute has been specified.</td> 1530 </tr> 1531 <tr> 1532 <td>file</td> 1533 <td>String</td> 1534 <td> 1535 Name of the file to load definitions from. 1536 </td> 1537 <td>n/a</td> 1538 <td>No</td> 1525 1539 </tr> 1526 1540 <tr> branches/2.4/test/classes/example/tasks/TaskdefTestSimpleTask.php
r144 r367 36 36 37 37 public function main() { 38 $this->log("simpletask: " . $echo->message, Project::MSG_INFO);38 $this->log("simpletask: " . $this->echo->message, Project::MSG_INFO); 39 39 } 40 40 branches/2.4/test/run-tests.php
r123 r367 58 58 include_once 'phing/tasks/TypedefTaskTest.php'; 59 59 $tasksSuite->addTestSuite(new ReflectionClass('TypedefTaskTest')); 60 include_once 'phing/tasks/TaskdefTaskTest.php'; 61 $tasksSuite->addTestSuite(new ReflectionClass('TaskdefTaskTest')); 60 62 61 63
