diff options
Diffstat (limited to 'buildscripts/phing/classes/phing/tasks/system')
53 files changed, 2545 insertions, 831 deletions
diff --git a/buildscripts/phing/classes/phing/tasks/system/AdhocTask.php b/buildscripts/phing/classes/phing/tasks/system/AdhocTask.php index e4c291a1..ce0ca210 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/AdhocTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/AdhocTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: AdhocTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 03a742eb03e5e1515c297d941970a86b00e1f69e $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,7 +31,7 @@ require_once 'phing/Task.php'; * Subclasses exist for conveniently declaring and registering tasks and types. * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.6 $ + * @version $Id$ * @package phing.tasks.system */ class AdhocTask extends Task { @@ -51,10 +51,10 @@ class AdhocTask extends Task { $this->execute(); if ($this->newClasses) { foreach($this->newClasses as $classname) { - $this->log("Added adhoc class " . $classname, PROJECT_MSG_VERBOSE); + $this->log("Added adhoc class " . $classname, Project::MSG_VERBOSE); } } else { - $this->log("Adhoc task executed but did not result in any new classes.", PROJECT_MSG_VERBOSE); + $this->log("Adhoc task executed but did not result in any new classes.", Project::MSG_VERBOSE); } } 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); } } diff --git a/buildscripts/phing/classes/phing/tasks/system/AdhocTypedefTask.php b/buildscripts/phing/classes/phing/tasks/system/AdhocTypedefTask.php index b836ad93..80be2fc9 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/AdhocTypedefTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/AdhocTypedefTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: AdhocTypedefTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 679ed701a01fef022a2da8ff5db16cff658b77e6 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -26,7 +26,7 @@ require_once 'phing/tasks/system/AdhocTask.php'; * A class for creating adhoc datatypes in build file. * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.4 $ + * @version $Id$ * @package phing.tasks.system */ class AdhocTypedefTask extends AdhocTask { @@ -65,7 +65,7 @@ class AdhocTypedefTask extends AdhocTask { throw new BuildException("The adhoc class you defined must be an instance of phing.ProjectComponent", $this->location); } - $this->log("Datatype " . $this->name . " will be handled by class " . $classname, PROJECT_MSG_VERBOSE); + $this->log("Datatype " . $this->name . " will be handled by class " . $classname, Project::MSG_VERBOSE); $this->project->addDataTypeDefinition($this->name, $classname); } } diff --git a/buildscripts/phing/classes/phing/tasks/system/AppendTask.php b/buildscripts/phing/classes/phing/tasks/system/AppendTask.php index feb797cf..a7c4dcda 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/AppendTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/AppendTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: AppendTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 056086ae305f5447baee1a4c7b1ad59ceb8cf50b $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -48,7 +48,7 @@ include_once 'phing/types/FileSet.php'; * </append> * </code> * @package phing.tasks.system - * @version $Revision: 1.14 $ + * @version $Id$ */ class AppendTask extends Task { @@ -80,7 +80,7 @@ class AppendTask extends Task { * @deprecated Will be removed with final release. */ function setTo(PhingFile $f) { - $this->log("The 'to' attribute is deprecated in favor of 'destFile'; please update your code.", PROJECT_MSG_WARN); + $this->log("The 'to' attribute is deprecated in favor of 'destFile'; please update your code.", Project::MSG_WARN); $this->to = $f; } @@ -165,7 +165,7 @@ class AppendTask extends Task { // out for better performance(?) $lines = explode("\n", $this->text); foreach($lines as $line) { - $this->log($line, PROJECT_MSG_VERBOSE); + $this->log($line, Project::MSG_VERBOSE); } $writer->write($this->text); @@ -177,7 +177,7 @@ class AppendTask extends Task { try { $this->appendFile($writer, $this->file); } catch (Exception $ioe) { - $this->log("Unable to append contents of file " . $this->file->getAbsolutePath() . ": " . $ioe->getMessage(), PROJECT_MSG_WARN); + $this->log("Unable to append contents of file " . $this->file->getAbsolutePath() . ": " . $ioe->getMessage(), Project::MSG_WARN); } } @@ -187,7 +187,7 @@ class AppendTask extends Task { $files = $fl->getFiles($this->project); $this->appendFiles($writer, $files, $fl->getDir($this->project)); } catch (BuildException $be) { - $this->log($be->getMessage(), PROJECT_MSG_WARN); + $this->log($be->getMessage(), Project::MSG_WARN); } } @@ -197,7 +197,7 @@ class AppendTask extends Task { $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); $this->appendFiles($writer, $files, $fs->getDir($this->project)); } catch (BuildException $be) { - $this->log($be->getMessage(), PROJECT_MSG_WARN); + $this->log($be->getMessage(), Project::MSG_WARN); } } @@ -224,7 +224,7 @@ class AppendTask extends Task { $pathSlot->setValue($f->getPath()); $this->appendFile($writer, $f); } catch (Exception $ioe) { - $this->log("Unable to append contents of file " . $f->getAbsolutePath() . ": " . $ioe->getMessage(), PROJECT_MSG_WARN); + $this->log("Unable to append contents of file " . $f->getAbsolutePath() . ": " . $ioe->getMessage(), Project::MSG_WARN); } } } // if !empty diff --git a/buildscripts/phing/classes/phing/tasks/system/AvailableTask.php b/buildscripts/phing/classes/phing/tasks/system/AvailableTask.php index 76de3e40..bd5701e4 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/AvailableTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/AvailableTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: AvailableTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 7388bc66c9574987edd02ad3b2d6f14462f6b157 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -28,23 +28,25 @@ include_once 'phing/tasks/system/condition/ConditionBase.php'; * Note: implements condition interface (see condition/Condition.php) * * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.11 $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @package phing.tasks.system */ class AvailableTask extends Task { /** Property to check for. */ private $property; - + /** Value property should be set to. */ private $value = "true"; - + /** Resource to check for */ private $resource; - + private $type = null; private $filepath = null; + + private $followSymlinks = false; function setProperty($property) { $this->property = (string) $property; @@ -65,6 +67,36 @@ class AvailableTask extends Task { function setType($type) { $this->type = (string) strtolower($type); } + + public function setFollowSymlinks($followSymlinks) + { + $this->followSymlinks = (bool) $followSymlinks; + } + + /** + * Set the path to use when looking for a file. + * + * @param Path $filepath a Path instance containing the search path for files. + */ + public function setFilepath(Path $filepath) { + if ($this->filepath === null) { + $this->filepath = $filepath; + } else { + $this->filepath->append($filepath); + } + } + + /** + * Creates a path to be configured + * + * @return Path + */ + public function createFilepath() { + if ($this->filepath === null) { + $this->filepath = new Path($this->project); + } + return $this->filepath->createPath(); + } function main() { if ($this->property === null) { @@ -77,20 +109,20 @@ class AvailableTask extends Task { function evaluate() { if ($this->file === null && $this->resource === null) { - throw new BuildException("At least one of (file|resource) is required", $this->location); + throw new BuildException("At least one of (file|resource) is required", $this->location); } if ($this->type !== null && ($this->type !== "file" && $this->type !== "dir")) { throw new BuildException("Type must be one of either dir or file", $this->location); } - + if (($this->file !== null) && !$this->_checkFile()) { - $this->log("Unable to find " . $this->file->__toString() . " to set property " . $this->property, PROJECT_MSG_VERBOSE); + $this->log("Unable to find " . $this->file->__toString() . " to set property " . $this->property, Project::MSG_VERBOSE); return false; } if (($this->resource !== null) && !$this->_checkResource($this->resource)) { - $this->log("Unable to load resource " . $this->resource . " to set property " . $this->property, PROJECT_MSG_VERBOSE); + $this->log("Unable to load resource " . $this->resource . " to set property " . $this->property, Project::MSG_VERBOSE); return false; } @@ -98,13 +130,13 @@ class AvailableTask extends Task { } // this is prepared for the path type - function _checkFile() { + private function _checkFile() { if ($this->filepath === null) { return $this->_checkFile1($this->file); } else { - $paths = $this->filepath->listDir(); + $paths = $this->filepath->listPaths(); for($i=0,$pcnt=count($paths); $i < $pcnt; $i++) { - $this->log("Searching " . $paths[$i], PROJECT_MSG_VERBOSE); + $this->log("Searching " . $paths[$i], Project::MSG_VERBOSE); $tmp = new PhingFile($paths[$i], $this->file->getName()); if($tmp->isFile()) { return true; @@ -114,7 +146,12 @@ class AvailableTask extends Task { return false; } - function _checkFile1($file) { + private function _checkFile1(PhingFile $file) { + // Resolve symbolic links + if ($this->followSymlinks && $file->isLink()) { + $file = new PhingFile($file->getLinkTarget()); + } + if ($this->type !== null) { if ($this->type === "dir") { return $file->isDirectory(); @@ -124,9 +161,12 @@ class AvailableTask extends Task { } return $file->exists(); } - - function _checkResource($resource) { - return $this->_checkFile1(new PhingFile(Phing::getResourcePath($resource))); + + private function _checkResource($resource) { + if (null != ($resourcePath = Phing::getResourcePath($resource))) { + return $this->_checkFile1(new PhingFile($resourcePath)); + } else { + return false; + } } - } diff --git a/buildscripts/phing/classes/phing/tasks/system/ChmodTask.php b/buildscripts/phing/classes/phing/tasks/system/ChmodTask.php index 80470dea..b2300459 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ChmodTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ChmodTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ChmodTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: fad30caf32ff1ee9ff98f63849d61053ab88f645 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,7 +27,7 @@ include_once 'phing/types/FileSet.php'; * * @author Manuel Holtgrewe <grin@gmx.net> * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.12 $ + * @version $Id: fad30caf32ff1ee9ff98f63849d61053ab88f645 $ * @package phing.tasks.system */ class ChmodTask extends Task { @@ -39,21 +39,22 @@ class ChmodTask extends Task { private $filesets = array(); private $filesystem; - - private $quiet = false; - private $failonerror = true; - - /** - * This flag means 'note errors to the output, but keep going' - * @see setQuiet() - */ + + private $quiet = false; + private $failonerror = true; + private $verbose = true; + + /** + * This flag means 'note errors to the output, but keep going' + * @see setQuiet() + */ function setFailonerror($bool) { $this->failonerror = $bool; - } + } /** * Set quiet mode, which suppresses warnings if chmod() fails. - * @see setFailonerror() + * @see setFailonerror() */ function setQuiet($bool) { $this->quiet = $bool; @@ -61,7 +62,15 @@ class ChmodTask extends Task { $this->failonerror = false; } } - + + /** + * Set verbosity, which if set to false surpresses all but an overview + * of what happened. + */ + function setVerbose($bool) { + $this->verbose = (bool)$bool; + } + /** * Sets a single source file to touch. If the file does not exist * an empty file will be created. @@ -118,16 +127,21 @@ class ChmodTask extends Task { * @return void */ private function chmod() { - - if (strlen($this->mode) === 4) { - $mode = octdec($this->mode); - } else { - // we need to prepend the 0 before converting - $mode = octdec("0". $this->mode); - } + + if (strlen($this->mode) === 4) { + $mode = octdec($this->mode); + } else { + // we need to prepend the 0 before converting + $mode = octdec("0". $this->mode); + } + + // counters for non-verbose output + $total_files = 0; + $total_dirs = 0; // one file if ($this->file !== null) { + $total_files = 1; $this->chmodFile($this->file, $mode); } @@ -140,38 +154,50 @@ class ChmodTask extends Task { $srcFiles = $ds->getIncludedFiles(); $srcDirs = $ds->getIncludedDirectories(); - for ($j = 0, $filecount = count($srcFiles); $j < $filecount; $j++) { + $filecount = count($srcFiles); + $total_files = $total_files + $filecount; + for ($j = 0; $j < $filecount; $j++) { $this->chmodFile(new PhingFile($fromDir, $srcFiles[$j]), $mode); } - for ($j = 0, $dircount = count($srcDirs); $j < $dircount; $j++) { + $dircount = count($srcDirs); + $total_dirs = $total_dirs + $dircount; + for ($j = 0; $j < $dircount; $j++) { $this->chmodFile(new PhingFile($fromDir, $srcDirs[$j]), $mode); } } + if (!$this->verbose) { + $this->log('Total files changed to ' . vsprintf('%o', $mode) . ': ' . $total_files); + $this->log('Total directories changed to ' . vsprintf('%o', $mode) . ': ' . $total_dirs); + } + } - /** - * Actually change the mode for the file. - * @param PhingFile $file - * @param int $mode - */ + /** + * Actually change the mode for the file. + * @param PhingFile $file + * @param int $mode + */ private function chmodFile(PhingFile $file, $mode) { if ( !$file->exists() ) { throw new BuildException("The file " . $file->__toString() . " does not exist"); } - - try { - $file->setMode($mode); - $this->log("Changed file mode on '" . $file->__toString() ."' to " . vsprintf("%o", $mode)); - } catch (Exception $e) { - if($this->failonerror) { - throw $e; - } else { - $this->log($e->getMessage(), $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); - } - } + + try { + $file->setMode($mode); + if ($this->verbose) { + $this->log("Changed file mode on '" . $file->__toString() ."' to " . vsprintf("%o", $mode)); + } + } catch (Exception $e) { + if($this->failonerror) { + throw $e; + } else { + $this->log($e->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); + } + } } - + } + diff --git a/buildscripts/phing/classes/phing/tasks/system/ChownTask.php b/buildscripts/phing/classes/phing/tasks/system/ChownTask.php new file mode 100755 index 00000000..60b8105c --- /dev/null +++ b/buildscripts/phing/classes/phing/tasks/system/ChownTask.php @@ -0,0 +1,216 @@ +<?php +/* + * $Id: f7234abd52e7f80177f4b121436ae7276370993c $ + * + * 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/Task.php'; +include_once 'phing/types/FileSet.php'; + +/** + * Task that changes the permissions on a file/directory. + * + * @author Mehmet Emre Yilmaz <mehmety@gmail.com> + * @version $Id: f7234abd52e7f80177f4b121436ae7276370993c $ + * @package phing.tasks.system + */ +class ChownTask extends Task { + + private $file; + + private $user; + private $group; + + private $filesets = array(); + + private $filesystem; + + private $quiet = false; + private $failonerror = true; + private $verbose = true; + + /** + * This flag means 'note errors to the output, but keep going' + * @see setQuiet() + */ + function setFailonerror($bool) { + $this->failonerror = $bool; + } + + /** + * Set quiet mode, which suppresses warnings if chown() fails. + * @see setFailonerror() + */ + function setQuiet($bool) { + $this->quiet = $bool; + if ($this->quiet) { + $this->failonerror = false; + } + } + + /** + * Set verbosity, which if set to false surpresses all but an overview + * of what happened. + */ + function setVerbose($bool) { + $this->verbose = (bool)$bool; + } + + /** + * Sets a single source file to touch. If the file does not exist + * an empty file will be created. + */ + function setFile(PhingFile $file) { + $this->file = $file; + } + + /** + * Sets the user + */ + function setUser($user) { + $this->user = $user; + } + + /** + * Sets the group + */ + function setGroup($group) { + $this->group = $group; + } + + /** + * Nested creator, adds a set of files (nested fileset attribute). + */ + function addFileSet(FileSet $fs) { + $this->filesets[] = $fs; + } + + /** + * Execute the touch operation. + * @return void + */ + function main() { + // Check Parameters + $this->checkParams(); + $this->chown(); + } + + /** + * Ensure that correct parameters were passed in. + * @return void + */ + private function checkParams() { + + if ($this->file === null && empty($this->filesets)) { + throw new BuildException("Specify at least one source - a file or a fileset."); + } + + if ($this->user === null && $this->group === null) { + throw new BuildException("You have to specify either an owner or a group for chown."); + } + } + + /** + * Does the actual work. + * @return void + */ + private function chown() { + $userElements = explode('.', $this->user); + + $user = $userElements[0]; + + if (count($userElements) > 1) { + $group = $userElements[1]; + } else { + $group = $this->group; + } + + // counters for non-verbose output + $total_files = 0; + $total_dirs = 0; + + // one file + if ($this->file !== null) { + $total_files = 1; + $this->chownFile($this->file, $user, $group); + } + + // filesets + foreach($this->filesets as $fs) { + + $ds = $fs->getDirectoryScanner($this->project); + $fromDir = $fs->getDir($this->project); + + $srcFiles = $ds->getIncludedFiles(); + $srcDirs = $ds->getIncludedDirectories(); + + $filecount = count($srcFiles); + $total_files = $total_files + $filecount; + for ($j = 0; $j < $filecount; $j++) { + $this->chownFile(new PhingFile($fromDir, $srcFiles[$j]), $user, $group); + } + + $dircount = count($srcDirs); + $total_dirs = $total_dirs + $dircount; + for ($j = 0; $j < $dircount; $j++) { + $this->chownFile(new PhingFile($fromDir, $srcDirs[$j]), $user, $group); + } + } + + if (!$this->verbose) { + $this->log('Total files changed to ' . $user . ($group ? "." . $group : "") . ': ' . $total_files); + $this->log('Total directories changed to ' . $user . ($group ? "." . $group : "") . ': ' . $total_dirs); + } + + } + + /** + * Actually change the mode for the file. + * @param PhingFile $file + * @param string $user + * @param string $group + */ + private function chownFile(PhingFile $file, $user, $group = "") { + if ( !$file->exists() ) { + throw new BuildException("The file " . $file->__toString() . " does not exist"); + } + + try { + if (!empty($user)) { + $file->setUser($user); + } + + if (!empty($group)) { + $file->setGroup($group); + } + + if ($this->verbose) { + $this->log("Changed file owner on '" . $file->__toString() ."' to " . $user . ($group ? "." . $group : "")); + } + } catch (Exception $e) { + if($this->failonerror) { + throw $e; + } else { + $this->log($e->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); + } + } + } + +} + + diff --git a/buildscripts/phing/classes/phing/tasks/system/ConditionTask.php b/buildscripts/phing/classes/phing/tasks/system/ConditionTask.php index fe6ee60b..040fff8a 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ConditionTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ConditionTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ConditionTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 31dfd9d24212a4cf5afcce43a9ae337669bafc35 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,8 +31,8 @@ require_once 'phing/tasks/system/condition/ConditionBase.php'; * ConditionBase.</p> * * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.7 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @access public * @package phing.tasks.system */ diff --git a/buildscripts/phing/classes/phing/tasks/system/CopyTask.php b/buildscripts/phing/classes/phing/tasks/system/CopyTask.php index c5e4c2a5..2533bb95 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/CopyTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/CopyTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: CopyTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 86322e73609da671413e4c959082958c16a510cc $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information please see * <http://phing.info>. */ - + require_once 'phing/Task.php'; include_once 'phing/system/io/PhingFile.php'; include_once 'phing/util/FileUtils.php'; @@ -33,27 +33,33 @@ include_once 'phing/mappers/FlattenMapper.php'; * exist. It is possible to explictly overwrite existing files. * * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.16 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @version $Id: 86322e73609da671413e4c959082958c16a510cc $ * @package phing.tasks.system */ class CopyTask extends Task { - + protected $file = null; // the source file (from xml attribute) protected $destFile = null; // the destiantion file (from xml attribute) protected $destDir = null; // the destination dir (from xml attribute) protected $overwrite = false; // overwrite destination (from xml attribute) - protected $preserveLMT = true; // sync timestamps (from xml attribute) + protected $preserveLMT = false; // sync timestamps (from xml attribute) protected $includeEmpty = true; // include empty dirs? (from XML) protected $flatten = false; // apply the FlattenMapper right way (from XML) protected $mapperElement = null; protected $fileCopyMap = array(); // asoc array containing mapped file names protected $dirCopyMap = array(); // asoc array containing mapped file names + protected $completeDirMap= array(); // asoc array containing complete dir names protected $fileUtils = null; // a instance of fileutils protected $filesets = array(); // all fileset objects assigned to this task + protected $filelists = array(); // all filelist objects assigned to this task protected $filterChains = array(); // all filterchains objects assigned to this task - protected $verbosity = PROJECT_MSG_VERBOSE; + protected $verbosity = Project::MSG_VERBOSE; + + protected $mode = 0755; // mode to create directories with + + protected $haltonerror = true; // stop build on errors /** * Sets up this object internal stuff. i.e. the Fileutils instance @@ -84,14 +90,21 @@ class CopyTask extends Task { */ function setVerbose($verbosity) { if ($verbosity) { - $this->verbosity = PROJECT_MSG_INFO; + $this->verbosity = Project::MSG_INFO; } else { - $this->verbosity = PROJECT_MSG_VERBOSE; + $this->verbosity = Project::MSG_VERBOSE; } } - + /** - * Set the preserve timestmap flag. IntrospectionHelper takes care of + * @see CopyTask::setPreserveLastModified + */ + function setTstamp($bool) { + $this->setPreserveLastModified($bool); + } + + /** + * Set the preserve timestamp flag. IntrospectionHelper takes care of * booleans in set* methods so we can assume that the right * value (boolean primitive) is coming in here. * @@ -99,11 +112,10 @@ class CopyTask extends Task { * @return void * @access public */ - function setTstamp($bool) { + function setPreserveLastModified($bool) { $this->preserveLMT = (boolean) $bool; } - /** * Set the include empty dirs flag. IntrospectionHelper takes care of * booleans in set* methods so we can assume that the right @@ -127,7 +139,7 @@ class CopyTask extends Task { * @return void * @access public */ - function setFile(PhingFile $file) { + function setFile(PhingFile $file) { $this->file = $file; } @@ -141,10 +153,21 @@ class CopyTask extends Task { * @return void * @access public */ - function setTofile(PhingFile $file) { + function setTofile(PhingFile $file) { $this->destFile = $file; } + /** + * Sets the mode to create destination directories with (ignored on Windows). + * Default mode is 0755. + * + * @param integer Octal mode + * @return void + * @access public + */ + function setMode($mode) { + $this->mode = (int) base_convert($mode, 8, 10); + } /** * Set the toDir. We have to manually take care of the @@ -155,22 +178,44 @@ class CopyTask extends Task { * @return void * @access public */ - function setTodir(PhingFile $dir) { + function setTodir(PhingFile $dir) { $this->destDir = $dir; } /** + * Set the haltonerror attribute - when true, will + * make the build fail when errors are detected. + * + * @param boolean Flag if the build should be stopped on errors + * @return void + * @access public + */ + function setHaltonerror($haltonerror) { + $this->haltonerror = (boolean) $haltonerror; + } + + /** * Nested creator, creates a FileSet for this task * - * @access public - * @return object The created fileset object + * @param FileSet $fileset Set of files to copy + * + * @return void */ - function createFileSet() { - $num = array_push($this->filesets, new FileSet()); - return $this->filesets[$num-1]; + public function addFileSet(FileSet $fs) { + $this->filesets[] = $fs; } /** + * Nested creator, adds a set of files (nested fileset attribute). + * + * @access public + * @return object The created filelist object + */ + function createFileList() { + $num = array_push($this->filelists, new FileList()); + return $this->filelists[$num-1]; + } + /** * Creates a filterchain * * @access public @@ -204,7 +249,7 @@ class CopyTask extends Task { * @throws BuildException */ function main() { - + $this->validateAttributes(); if ($this->file !== null) { @@ -219,18 +264,38 @@ class CopyTask extends Task { } } else { // terminate build - throw new BuildException("Could not find file " . $this->file->__toString() . " to copy."); + $this->logError("Could not find file " . $this->file->__toString() . " to copy."); } } $project = $this->getProject(); + // process filelists + foreach($this->filelists as $fl) { + $fromDir = $fl->getDir($project); + $srcFiles = $fl->getFiles($project); + $srcDirs = array($fl->getDir($project)); + + if (!$this->flatten && $this->mapperElement === null) + { + $this->completeDirMap[$fromDir->getAbsolutePath()] = $this->destDir->getAbsolutePath(); + } + + $this->_scan($fromDir, $this->destDir, $srcFiles, $srcDirs); + } + // process filesets foreach($this->filesets as $fs) { $ds = $fs->getDirectoryScanner($project); $fromDir = $fs->getDir($project); $srcFiles = $ds->getIncludedFiles(); $srcDirs = $ds->getIncludedDirectories(); + + if (!$this->flatten && $this->mapperElement === null) + { + $this->completeDirMap[$fromDir->getAbsolutePath()] = $this->destDir->getAbsolutePath(); + } + $this->_scan($fromDir, $this->destDir, $srcFiles, $srcDirs); } @@ -249,10 +314,10 @@ class CopyTask extends Task { * @return void * @throws BuildException */ - private function validateAttributes() { - - if ($this->file === null && count($this->filesets) === 0) { - throw new BuildException("CopyTask. Specify at least one source - a file or a fileset."); + protected function validateAttributes() { + + if ($this->file === null && count($this->filesets) === 0 && count($this->filelists) === 0) { + throw new BuildException("CopyTask. Specify at least one source - a file, fileset or filelist."); } if ($this->destFile !== null && $this->destDir !== null) { @@ -295,7 +360,7 @@ class CopyTask extends Task { $mapper = new IdentityMapper(); } $this->buildMap($fromDir, $toDir, $files, $mapper, $this->fileCopyMap); - $this->buildMap($fromDir, $toDir, $dirs, $mapper, $this->dirCopyMap); + $this->buildMap($fromDir, $toDir, $dirs, $mapper, $this->dirCopyMap); } /** @@ -336,17 +401,41 @@ class CopyTask extends Task { * @return void * @throws BuildException */ - private function doWork() { + protected function doWork() { + + // These "slots" allow filters to retrieve information about the currently-being-process files + $fromSlot = $this->getRegisterSlot("currentFromFile"); + $fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename"); + + $toSlot = $this->getRegisterSlot("currentToFile"); + $toBasenameSlot = $this->getRegisterSlot("currentToFile.basename"); + + $mapSize = count($this->fileCopyMap); + $total = $mapSize; - // These "slots" allow filters to retrieve information about the currently-being-process files - $fromSlot = $this->getRegisterSlot("currentFromFile"); - $fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename"); + // handle empty dirs if appropriate + if ($this->includeEmpty) { + $count = 0; + foreach ($this->dirCopyMap as $srcdir => $destdir) { + $s = new PhingFile((string) $srcdir); + $d = new PhingFile((string) $destdir); + if (!$d->exists()) { + if (!$d->mkdirs()) { + $this->logError("Unable to create directory " . $d->__toString()); + } else { + if ($this->preserveLMT) { + $d->setLastModified($s->lastModified()); + } - $toSlot = $this->getRegisterSlot("currentToFile"); - $toBasenameSlot = $this->getRegisterSlot("currentToFile.basename"); + $count++; + } + } + } + if ($count > 0) { + $this->log("Created ".$count." empty director" . ($count == 1 ? "y" : "ies") . " in " . $this->destDir->getAbsolutePath()); + } + } - $mapSize = count($this->fileCopyMap); - $total = $mapSize; if ($mapSize > 0) { $this->log("Copying ".$mapSize." file".(($mapSize) === 1 ? '' : 's')." to ". $this->destDir->getAbsolutePath()); // walks the map and actually copies the files @@ -359,42 +448,32 @@ class CopyTask extends Task { } $this->log("From ".$from." to ".$to, $this->verbosity); try { // try to copy file - - $fromFile = new PhingFile($from); - $toFile = new PhingFile($to); - + + $fromFile = new PhingFile($from); + $toFile = new PhingFile($to); + $fromSlot->setValue($fromFile->getPath()); - $fromBasenameSlot->setValue($fromFile->getName()); - - $toSlot->setValue($toFile->getPath()); - $toBasenameSlot->setValue($toFile->getName()); - - $this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject()); + $fromBasenameSlot->setValue($fromFile->getName()); + $toSlot->setValue($toFile->getPath()); + $toBasenameSlot->setValue($toFile->getName()); + + $this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject(), $this->mode); + $count++; } catch (IOException $ioe) { - $this->log("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage(), PROJECT_MSG_ERR); + $this->logError("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage()); } } } - - // handle empty dirs if appropriate - if ($this->includeEmpty) { - $e = array_values($this->dirCopyMap); - $count = 0; - foreach ($e as $dir) { - $d = new PhingFile((string) $dir); - if (!$d->exists()) { - if (!$d->mkdirs()) { - $this->log("Unable to create directory " . $d->__toString(), PROJECT_MSG_ERR); - } else { - $count++; - } - } - } - if ($count > 0) { - $this->log("Copied ".$count." empty director" . ($count == 1 ? "y" : "ies") . " to " . $this->destDir->getAbsolutePath()); - } + } + + protected function logError($message, $location = NULL) + { + if ($this->haltonerror) { + throw new BuildException($message, $location); + } else { + $this->log($message, Project::MSG_ERR); } } diff --git a/buildscripts/phing/classes/phing/tasks/system/CvsPassTask.php b/buildscripts/phing/classes/phing/tasks/system/CvsPassTask.php index 0003c50f..87a9b63c 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/CvsPassTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/CvsPassTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: CvsPassTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: c1e02a8d43f62c584ba2f1cd5a6f0cc690bceb94 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,7 +29,7 @@ include_once 'phing/util/StringHelper.php'; * * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Jeff Martin <jeff@custommonkey.org> (Ant) - * @version $Revision: 1.7 $ + * @version $Id$ * @package phing.tasks.system */ class CVSPassTask extends Task { @@ -84,9 +84,9 @@ class CVSPassTask extends Task { throw new BuildException("password is required"); } - $this->log("cvsRoot: " . $this->cvsRoot, PROJECT_MSG_DEBUG); - $this->log("password: " . $this->password, PROJECT_MSG_DEBUG); - $this->log("passFile: " . $this->passFile->__toString(), PROJECT_MSG_DEBUG); + $this->log("cvsRoot: " . $this->cvsRoot, Project::MSG_DEBUG); + $this->log("password: " . $this->password, Project::MSG_DEBUG); + $this->log("passFile: " . $this->passFile->__toString(), Project::MSG_DEBUG); $reader = null; $writer = null; @@ -100,14 +100,14 @@ class CVSPassTask extends Task { $line = null; while (($line = $reader->readLine()) !== null) { if (!StringHelper::startsWith($this->cvsRoot, $line)) { - $buf .= $line . Phing::getProperty("line.separator"); + $buf .= $line . PHP_EOL; } } } $pwdfile = $buf . $this->cvsRoot . " A" . $this->mangle($this->password); - $this->log("Writing -> " . $pwdfile , PROJECT_MSG_DEBUG); + $this->log("Writing -> " . $pwdfile , Project::MSG_DEBUG); $writer = new BufferedWriter(new FileWriter($this->passFile)); $writer->write($pwdfile); diff --git a/buildscripts/phing/classes/phing/tasks/system/CvsTask.php b/buildscripts/phing/classes/phing/tasks/system/CvsTask.php index de2950ec..3c12a597 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/CvsTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/CvsTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: CvsTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 642c6947fa58e02a8c7893c8c4dfab2debfdd51d $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -35,7 +35,7 @@ include_once 'phing/types/Commandline.php'; * @author stefano@apache.org (Ant) * @author Wolfgang Werner <wwerner@picturesafe.de> (Ant) * @author Kevin Ross <kevin.ross@bredex.com> (Ant) - * @version $Revision: 1.14 $ + * @version $Id: 642c6947fa58e02a8c7893c8c4dfab2debfdd51d $ * @package phing.tasks.system */ class CvsTask extends Task { @@ -155,14 +155,14 @@ class CvsTask extends Task { if ($this->passFile !== null) { if ($this->passFile->isFile() && $this->passFile->canRead()) { putenv("CVS_PASSFILE=" . $this->passFile->__toString()); - $this->log("Using cvs passfile: " . $this->passFile->__toString(), PROJECT_MSG_INFO); + $this->log("Using cvs passfile: " . $this->passFile->__toString(), Project::MSG_INFO); } elseif (!$this->passFile->canRead()) { $this->log("cvs passfile: " . $this->passFile->__toString() - . " ignored as it is not readable", PROJECT_MSG_WARN); + . " ignored as it is not readable", Project::MSG_WARN); } else { $this->log("cvs passfile: " . $this->passFile->__toString() . " ignored as it is not a file", - PROJECT_MSG_WARN); + Project::MSG_WARN); } } @@ -201,14 +201,14 @@ class CvsTask extends Task { try { $actualCommandLine = $toExecuteStr; // we converted to string above - $this->log($actualCommandLine, PROJECT_MSG_INFO); - $retCode = $exe->execute(); - $this->log("retCode=" . $retCode, PROJECT_MSG_DEBUG); + $this->log($actualCommandLine, Project::MSG_INFO); + $retCode = $exe->main(); + $this->log("retCode=" . $retCode, Project::MSG_DEBUG); /*Throw an exception if cvs exited with error. (Iulian)*/ if ($this->failOnError && $retCode !== 0) { throw new BuildException("cvs exited with error code " . $retCode - . Phing::getProperty("line.separator") + . PHP_EOL . "Command line was [" . $toExecute->describeCommand() . "]", $this->getLocation()); } @@ -216,7 +216,7 @@ class CvsTask extends Task { if ($this->failOnError) { throw new BuildException($e, $this->getLocation()); } else { - $this->log("Caught exception: " . $e, PROJECT_MSG_WARN); + $this->log("Caught exception: " . $e, Project::MSG_WARN); } } catch (BuildException $e) { if ($this->failOnError) { @@ -226,13 +226,13 @@ class CvsTask extends Task { if ($t === null) { $t = $e; } - $this->log("Caught exception: " . $t, PROJECT_MSG_WARN); + $this->log("Caught exception: " . $t, Project::MSG_WARN); } } catch (Exception $e) { if ($this->failOnError) { throw new BuildException($e, $this->getLocation()); } else { - $this->log("Caught exception: " . $e, PROJECT_MSG_WARN); + $this->log("Caught exception: " . $e, Project::MSG_WARN); } } } diff --git a/buildscripts/phing/classes/phing/tasks/system/DeleteTask.php b/buildscripts/phing/classes/phing/tasks/system/DeleteTask.php index 00e1e7a7..8af8a632 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/DeleteTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/DeleteTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: DeleteTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: f25fc4c605ead65db9235c9fe328b2d47b7c8299 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -24,7 +24,7 @@ require_once 'phing/Task.php'; /** * Deletes a file or directory, or set of files defined by a fileset. * - * @version $Revision: 1.13 $ + * @version $Id: f25fc4c605ead65db9235c9fe328b2d47b7c8299 $ * @package phing.tasks.system */ class DeleteTask extends Task { @@ -36,11 +36,11 @@ class DeleteTask extends Task { protected $quiet = false; protected $failonerror = true; - protected $verbosity = PROJECT_MSG_VERBOSE; - - /** Any filelists of files that should be deleted. */ + protected $verbosity = Project::MSG_VERBOSE; + + /** Any filelists of files that should be deleted. */ private $filelists = array(); - + /** * Set the name of a single file to be removed. * @param PhingFile $file @@ -63,9 +63,9 @@ class DeleteTask extends Task { */ function setVerbose($verbosity) { if ($verbosity) { - $this->verbosity = PROJECT_MSG_INFO; + $this->verbosity = Project::MSG_INFO; } else { - $this->verbosity = PROJECT_MSG_VERBOSE; + $this->verbosity = Project::MSG_VERBOSE; } } @@ -96,12 +96,11 @@ class DeleteTask extends Task { } /** Nested creator, adds a set of files (nested fileset attribute). */ - function createFileSet() { - $num = array_push($this->filesets, new FileSet()); - return $this->filesets[$num-1]; + function addFileSet(FileSet $fs) { + $this->filesets[] = $fs; } - - /** Nested creator, adds a set of files (nested fileset attribute). */ + + /** Nested creator, adds a set of files (nested fileset attribute). */ function createFileList() { $num = array_push($this->filelists, new FileList()); return $this->filelists[$num-1]; @@ -131,38 +130,38 @@ class DeleteTask extends Task { if($this->failonerror) { throw new BuildException($message); } else { - $this->log($message, $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } } } else { - $this->log("Could not find file " . $this->file->getAbsolutePath() . " to delete.",PROJECT_MSG_VERBOSE); + $this->log("Could not find file " . $this->file->getAbsolutePath() . " to delete.",Project::MSG_VERBOSE); } } // delete the directory if ($this->dir !== null && $this->dir->exists() && $this->dir->isDirectory()) { - if ($this->verbosity === PROJECT_MSG_VERBOSE) { + if ($this->verbosity === Project::MSG_VERBOSE) { $this->log("Deleting directory " . $this->dir->__toString()); } $this->removeDir($this->dir); } - - // delete the files in the filelists - foreach($this->filelists as $fl) { - try { - $files = $fl->getFiles($this->project); - $this->removeFiles($fl->getDir($this->project), $files, $empty=array()); - } catch (BuildException $be) { - // directory doesn't exist or is not readable - if ($this->failonerror) { - throw $be; - } else { - $this->log($be->getMessage(), $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); - } - } - } - + + // delete the files in the filelists + foreach($this->filelists as $fl) { + try { + $files = $fl->getFiles($this->project); + $this->removeFiles($fl->getDir($this->project), $files, $empty=array()); + } catch (BuildException $be) { + // directory doesn't exist or is not readable + if ($this->failonerror) { + throw $be; + } else { + $this->log($be->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); + } + } + } + // delete the files in the filesets foreach($this->filesets as $fs) { try { @@ -175,7 +174,7 @@ class DeleteTask extends Task { if ($this->failonerror) { throw $be; } else { - $this->log($be->getMessage(), $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($be->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } } @@ -204,7 +203,7 @@ class DeleteTask extends Task { if($this->failonerror) { throw new BuildException($message); } else { - $this->log($message, $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } } @@ -217,7 +216,7 @@ class DeleteTask extends Task { if($this->failonerror) { throw new BuildException($message); } else { - $this->log($message, $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } } @@ -242,7 +241,7 @@ class DeleteTask extends Task { if($this->failonerror) { throw new BuildException($message); } else { - $this->log($message, $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } @@ -260,11 +259,11 @@ class DeleteTask extends Task { $dir->delete(); $dirCount++; } catch (Exception $e) { - $message="Unable to delete directory " + $dir; + $message="Unable to delete directory " . $dir->__toString(); if($this->failonerror) { throw new BuildException($message); } else { - $this->log($message, $this->quiet ? PROJECT_MSG_VERBOSE : PROJECT_MSG_WARN); + $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN); } } } diff --git a/buildscripts/phing/classes/phing/tasks/system/EchoTask.php b/buildscripts/phing/classes/phing/tasks/system/EchoTask.php index 229f5130..edc098c4 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/EchoTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/EchoTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: EchoTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: c5ebadd12256533d9ca4d6fb6cabd50415bdddbf $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -24,14 +24,14 @@ include_once 'phing/Task.php'; /** * Echos a message to the logging system or to a file * - * @author Michiel Rook <michiel@trendserver.nl> + * @author Michiel Rook <mrook@php.net> * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.5 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @version $Id$ * @package phing.tasks.system */ class EchoTask extends Task { - + protected $msg = ""; protected $file = ""; @@ -40,54 +40,87 @@ class EchoTask extends Task { protected $level = "info"; - function main() { - switch ($this->level) - { - case "error": $loglevel = PROJECT_MSG_ERR; break; - case "warning": $loglevel = PROJECT_MSG_WARN; break; - case "info": $loglevel = PROJECT_MSG_INFO; break; - case "verbose": $loglevel = PROJECT_MSG_VERBOSE; break; - case "debug": $loglevel = PROJECT_MSG_DEBUG; break; - } - - if (empty($this->file)) - { - $this->log($this->msg, $loglevel); - } - else - { - if ($this->append) - { - $handle = fopen($this->file, "a"); - } - else - { - $handle = fopen($this->file, "w"); - } - - fwrite($handle, $this->msg); - - fclose($handle); - } + protected $filesets = array(); + + function main() { + switch ($this->level) + { + case "error": $loglevel = Project::MSG_ERR; break; + case "warning": $loglevel = Project::MSG_WARN; break; + case "info": $loglevel = Project::MSG_INFO; break; + case "verbose": $loglevel = Project::MSG_VERBOSE; break; + case "debug": $loglevel = Project::MSG_DEBUG; break; + } + + if (count($this->filesets)) { + if (trim(substr($this->msg, -1)) != '') { + $this->msg .= "\n"; + } + $this->msg .= $this->getFilesetsMsg(); + } + + if (empty($this->file)) + { + $this->log($this->msg, $loglevel); + } + else + { + if ($this->append) + { + $handle = fopen($this->file, "a"); + } + else + { + $handle = fopen($this->file, "w"); + } + + fwrite($handle, $this->msg); + + fclose($handle); + } + } + + /** + * Merges all filesets into a string to be echoed out + * + * @return string String to echo + */ + protected function getFilesetsMsg() + { + $project = $this->getProject(); + $msg = ''; + foreach ($this->filesets as $fs) { + $ds = $fs->getDirectoryScanner($project); + $fromDir = $fs->getDir($project); + $srcFiles = $ds->getIncludedFiles(); + $msg .= 'Directory: ' . $fromDir . ' => ' + . realpath($fromDir) . "\n"; + foreach ($srcFiles as $file) { + $relPath = $fromDir . DIRECTORY_SEPARATOR . $file; + $msg .= $relPath . "\n"; + } + } + + return $msg; } /** setter for file */ function setFile($file) { - $this->file = (string) $file; - } + $this->file = (string) $file; + } /** setter for level */ function setLevel($level) { - $this->level = (string) $level; - } + $this->level = (string) $level; + } /** setter for append */ function setAppend($append) { - $this->append = $append; - } + $this->append = $append; + } /** setter for message */ function setMsg($msg) { @@ -104,4 +137,16 @@ class EchoTask extends Task { { $this->msg = (string) $msg; } + + /** + * Adds a fileset to echo the files of + * + * @param FileSet $fs Set of files to echo + * + * @return void + */ + public function addFileSet(FileSet $fs) + { + $this->filesets[] = $fs; + } } diff --git a/buildscripts/phing/classes/phing/tasks/system/ExecTask.php b/buildscripts/phing/classes/phing/tasks/system/ExecTask.php index 104f7697..f5a57948 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ExecTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ExecTask.php @@ -1,7 +1,7 @@ <?php -/* - * $Id: ExecTask.php 59 2006-04-28 14:49:47Z mrook $ +/** + * $Id: 3101d1403eeb4fe4fe8bae729b7d918b303de1cf $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -25,119 +25,223 @@ require_once 'phing/Task.php'; /** * Executes a command on the shell. * - * @author Andreas Aderhold <andi@binarycloud.com> - * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.17 $ - * @package phing.tasks.system + * @author Andreas Aderhold <andi@binarycloud.com> + * @author Hans Lellelid <hans@xmpl.org> + * @author Christian Weiske <cweiske@cweiske.de> + * @version $Id: 3101d1403eeb4fe4fe8bae729b7d918b303de1cf $ + * @package phing.tasks.system */ -class ExecTask extends Task { +class ExecTask extends Task +{ /** * Command to execute. * @var string */ protected $command; - + + /** + * Commandline managing object + * + * @var Commandline + */ + protected $commandline; + /** * Working directory. - * @var File + * @var PhingFile */ protected $dir; - + /** * Operating system. * @var string */ protected $os; - + /** * Whether to escape shell command using escapeshellcmd(). * @var boolean */ protected $escape = false; - + /** * Where to direct output. * @var File */ protected $output; - + /** - * Whether to passthru the output + * Whether to use PHP's passthru() function instead of exec() * @var boolean */ protected $passthru = false; + + /** + * Whether to log returned output as MSG_INFO instead of MSG_VERBOSE + * @var boolean + */ + protected $logOutput = false; /** + * Logging level for status messages + * @var integer + */ + protected $logLevel = Project::MSG_VERBOSE; + + /** * Where to direct error output. * @var File */ protected $error; - - /** - * If spawn is set then [unix] programs will redirect stdout and add '&'. - * @var boolean - */ - protected $spawn = false; - + + /** + * If spawn is set then [unix] programs will redirect stdout and add '&'. + * @var boolean + */ + protected $spawn = false; + + /** + * Property name to set with return value from exec call. + * + * @var string + */ + protected $returnProperty; + + /** + * Property name to set with output value from exec call. + * + * @var string + */ + protected $outputProperty; + /** * Whether to check the return code. * @var boolean */ protected $checkreturn = false; - + + + + public function __construct() + { + $this->commandline = new Commandline(); + } + /** * Main method: wraps execute() command. + * * @return void */ - public function main() { - $this->execute(); + public function main() + { + if (!$this->isApplicable()) { + return; + } + + $this->prepare(); + $this->buildCommand(); + list($return, $output) = $this->executeCommand(); + $this->cleanup($return, $output); } - + /** - * Executes a program and returns the return code. - * Output from command is logged at INFO level. - * @return int Return code from execution. + * Checks whether the command shall be executed + * + * @return boolean False if the exec command shall not be run */ - public function execute() { - - // test if os match - $myos = Phing::getProperty("os.name"); - $this->log("Myos = " . $myos, PROJECT_MSG_VERBOSE); - if (($this->os !== null) && (strpos($os, $myos) === false)) { + protected function isApplicable() + { + if ($this->os === null) { + return true; + } + + $myos = Phing::getProperty('os.name'); + $this->log('Myos = ' . $myos, Project::MSG_VERBOSE); + + if (strpos($this->os, $myos) !== false) { // this command will be executed only on the specified OS - $this->log("Not found in " . $os, PROJECT_MSG_VERBOSE); - return 0; + // OS matches + return true; } - - if ($this->dir !== null) { - if ($this->dir->isDirectory()) { - $currdir = getcwd(); - @chdir($this->dir->getPath()); - } else { - throw new BuildException("Can't chdir to:" . $this->dir->__toString()); - } + + $this->log( + sprintf( + 'Operating system %s not found in %s', + $myos, $this->os + ), + Project::MSG_VERBOSE + ); + return false; + } + + /** + * Prepares the command building and execution, i.e. + * changes to the specified directory. + * + * @return void + */ + protected function prepare() + { + if ($this->dir === null) { + return; } + // expand any symbolic links first + if (!$this->dir->getCanonicalFile()->isDirectory()) { + throw new BuildException( + "'" . (string) $this->dir . "' is not a valid directory" + ); + } + $this->currdir = getcwd(); + @chdir($this->dir->getPath()); + } - if ($this->escape == true) { - // FIXME - figure out whether this is correct behavior - $this->command = escapeshellcmd($this->command); + /** + * Builds the full command to execute and stores it in $command. + * + * @return void + * @uses $command + */ + protected function buildCommand() + { + if ($this->command === null && $this->commandline->getExecutable() === null) { + throw new BuildException( + 'ExecTask: Please provide "command" OR "executable"' + ); + } else if ($this->command === null) { + $this->command = Commandline::toString($this->commandline->getCommandline(), $this->escape); + } else if ($this->commandline->getExecutable() === null) { + //we need to escape the command only if it's specified directly + // commandline takes care of "executable" already + if ($this->escape == true) { + $this->command = escapeshellcmd($this->command); + } + } else { + throw new BuildException( + 'ExecTask: Either use "command" OR "executable"' + ); } - + if ($this->error !== null) { $this->command .= ' 2> ' . $this->error->getPath(); - $this->log("Writing error output to: " . $this->error->getPath()); + $this->log( + "Writing error output to: " . $this->error->getPath(), + $this->logLevel + ); } - + if ($this->output !== null) { $this->command .= ' 1> ' . $this->output->getPath(); - $this->log("Writing standard output to: " . $this->output->getPath()); + $this->log( + "Writing standard output to: " . $this->output->getPath(), + $this->logLevel + ); } elseif ($this->spawn) { - $this->command .= ' 1>/dev/null'; - $this->log("Sending ouptut to /dev/null"); - } - + $this->command .= ' 1>/dev/null'; + $this->log("Sending output to /dev/null", $this->logLevel); + } + // If neither output nor error are being written to file // then we'll redirect error to stdout so that we can dump // it to screen below. @@ -145,104 +249,268 @@ class ExecTask extends Task { if ($this->output === null && $this->error === null) { $this->command .= ' 2>&1'; } - - // we ignore the spawn boolean for windows - if ($this->spawn) { - $this->command .= ' &'; - } - $this->log("Executing command: " . $this->command); - + // we ignore the spawn boolean for windows + if ($this->spawn) { + $this->command .= ' &'; + } + } + + /** + * Executes the command and returns return code and output. + * + * @return array array(return code, array with output) + */ + protected function executeCommand() + { + $this->log("Executing command: " . $this->command, $this->logLevel); + $output = array(); $return = null; - exec($this->command, $output, $return); + + if ($this->passthru) { + passthru($this->command, $return); + } else { + exec($this->command, $output, $return); + } + return array($return, $output); + } + + /** + * Runs all tasks after command execution: + * - change working directory back + * - log output + * - verify return value + * + * @param integer $return Return code + * @param array $output Array with command output + * + * @return void + */ + protected function cleanup($return, $output) + { if ($this->dir !== null) { - @chdir($currdir); + @chdir($this->currdir); } - foreach($output as $line) { - $this->log($line, ($this->passthru ? PROJECT_MSG_INFO : PROJECT_MSG_VERBOSE)); + $outloglevel = $this->logOutput ? Project::MSG_INFO : Project::MSG_VERBOSE; + foreach ($output as $line) { + $this->log($line, $outloglevel); } - - if($return != 0 && $this->checkreturn) - { - throw new BuildException("Task exited with code $return"); + + if ($this->returnProperty) { + $this->project->setProperty($this->returnProperty, $return); + } + + if ($this->outputProperty) { + $this->project->setProperty( + $this->outputProperty, implode("\n", $output) + ); + } + + if ($return != 0 && $this->checkreturn) { + throw new BuildException("Task exited with code $return"); } - - return $return; } + /** * The command to use. + * * @param mixed $command String or string-compatible (e.g. w/ __toString()). + * + * @return void */ - function setCommand($command) { + public function setCommand($command) + { $this->command = "" . $command; } - + + /** + * The executable to use. + * + * @param mixed $executable String or string-compatible (e.g. w/ __toString()). + * + * @return void + */ + public function setExecutable($executable) + { + $this->commandline->setExecutable((string)$executable); + } + /** * Whether to use escapeshellcmd() to escape command. - * @param boolean $escape + * + * @param boolean $escape If the command shall be escaped or not + * + * @return void */ - function setEscape($escape) { + public function setEscape($escape) + { $this->escape = (bool) $escape; } - + /** - * Specify the workign directory for executing this command. - * @param PhingFile $dir + * Specify the working directory for executing this command. + * + * @param PhingFile $dir Working directory + * + * @return void */ - function setDir(PhingFile $dir) { + public function setDir(PhingFile $dir) + { $this->dir = $dir; } - + /** * Specify OS (or muliple OS) that must match in order to execute this command. - * @param string $os + * + * @param string $os Operating system string (e.g. "Linux") + * + * @return void */ - function setOs($os) { + public function setOs($os) + { $this->os = (string) $os; } - + /** * File to which output should be written. - * @param PhingFile $output + * + * @param PhingFile $f Output log file + * + * @return void */ - function setOutput(PhingFile $f) { + public function setOutput(PhingFile $f) + { $this->output = $f; } - + /** * File to which error output should be written. - * @param PhingFile $output + * + * @param PhingFile $f Error log file + * + * @return void */ - function setError(PhingFile $f) { + public function setError(PhingFile $f) + { $this->error = $f; } - + /** - * Whether to use passthru the output. - * @param boolean $passthru + * Whether to use PHP's passthru() function instead of exec() + * + * @param boolean $passthru If passthru shall be used + * + * @return void */ - function setPassthru($passthru) { + public function setPassthru($passthru) + { $this->passthru = (bool) $passthru; } - - /** - * Whether to suppress all output and run in the background. - * @param boolean $spawn - */ - function setSpawn($spawn) { - $this->spawn = (bool) $spawn; - } + + /** + * Whether to log returned output as MSG_INFO instead of MSG_VERBOSE + * + * @param boolean $logOutput If output shall be logged visibly + * + * @return void + */ + public function setLogoutput($logOutput) + { + $this->logOutput = (bool) $logOutput; + } + + /** + * Whether to suppress all output and run in the background. + * + * @param boolean $spawn If the command is to be run in the background + * + * @return void + */ + public function setSpawn($spawn) + { + $this->spawn = (bool) $spawn; + } /** * Whether to check the return code. - * @param boolean $checkreturn + * + * @param boolean $checkreturn If the return code shall be checked + * + * @return void + */ + public function setCheckreturn($checkreturn) + { + $this->checkreturn = (bool) $checkreturn; + } + + /** + * The name of property to set to return value from exec() call. + * + * @param string $prop Property name + * + * @return void + */ + public function setReturnProperty($prop) + { + $this->returnProperty = $prop; + } + + /** + * The name of property to set to output value from exec() call. + * + * @param string $prop Property name + * + * @return void + */ + public function setOutputProperty($prop) + { + $this->outputProperty = $prop; + } + + /** + * Set level of log messages generated (default = verbose) + * + * @param string $level Log level + * + * @return void + */ + public function setLevel($level) + { + switch ($level) { + case 'error': + $this->logLevel = Project::MSG_ERR; + break; + case 'warning': + $this->logLevel = Project::MSG_WARN; + break; + case 'info': + $this->logLevel = Project::MSG_INFO; + break; + case 'verbose': + $this->logLevel = Project::MSG_VERBOSE; + break; + case 'debug': + $this->logLevel = Project::MSG_DEBUG; + break; + default: + throw new BuildException( + sprintf('Unknown log level "%s"', $level) + ); + } + } + + /** + * Creates a nested <arg> tag. + * + * @return CommandlineArgument Argument object */ - function setCheckreturn($checkreturn) { - $this->checkreturn = (bool) $checkreturn; + public function createArg() + { + return $this->commandline->createArgument(); } } diff --git a/buildscripts/phing/classes/phing/tasks/system/ExitTask.php b/buildscripts/phing/classes/phing/tasks/system/FailTask.php index 7e08d369..92306842 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ExitTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/FailTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ExitTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 260a7f3caa499a33f0d3982f9a5cc9db222475a6 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,10 +27,10 @@ require_once 'phing/Task.php'; * * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Nico Seessle <nico@seessle.de> (Ant) - * @version $Revision: 1.7 $ + * @version $Id$ * @package phing.tasks.system */ -class ExitTask extends Task { +class FailTask extends Task { private $message; private $ifCondition; diff --git a/buildscripts/phing/classes/phing/tasks/system/ForeachTask.php b/buildscripts/phing/classes/phing/tasks/system/ForeachTask.php index a2a42665..e9b556d3 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ForeachTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ForeachTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ForeachTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 7acb78ab792426fa7d4edec53496cff8da5923eb $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -20,6 +20,8 @@ */ require_once 'phing/Task.php'; +require_once 'phing/system/io/FileSystem.php'; +include_once 'phing/mappers/FileNameMapper.php'; include_once 'phing/tasks/system/PhingTask.php'; /** @@ -43,7 +45,7 @@ include_once 'phing/tasks/system/PhingTask.php'; * * @author Jason Hines <jason@greenhell.com> * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.9 $ + * @version $Id$ * @package phing.tasks.system */ class ForeachTask extends Task { @@ -54,7 +56,10 @@ class ForeachTask extends Task { /** Name of parameter to pass to callee */ private $param; - /** Delimter that separates items in $list */ + /** Name of absolute path parameter to pass to callee */ + private $absparam; + + /** Delimiter that separates items in $list */ private $delimiter = ','; /** @@ -63,11 +68,36 @@ class ForeachTask extends Task { */ private $callee; + /** Array of filesets */ + private $filesets = array(); + + /** Instance of mapper **/ + private $mapperElement; + + /** + * Array of filelists + * @var array + */ + private $filelists = array(); + /** * Target to execute. * @var string */ private $calleeTarget; + + /** + * Total number of files processed + * @var integer + */ + private $total_files = 0; + + /** + * Total number of directories processed + * @var integer + */ + private $total_dirs = 0; + function init() { $this->callee = $this->project->createTask("phingcall"); @@ -82,11 +112,8 @@ class ForeachTask extends Task { * @return void */ function main() { - if ($this->list === null) { - throw new BuildException("Missing list to iterate through"); - } - if (trim($this->list) === '') { - return; + if ($this->list === null && count($this->filesets) == 0 && count($this->filelists) == 0) { + throw new BuildException("Need either list, nested fileset or nested filelist to iterate through"); } if ($this->param === null) { throw new BuildException("You must supply a property name to set on each iteration in param"); @@ -99,15 +126,135 @@ class ForeachTask extends Task { $callee->setTarget($this->calleeTarget); $callee->setInheritAll(true); $callee->setInheritRefs(true); + $mapper = null; + + if ($this->mapperElement !== null) { + $mapper = $this->mapperElement->getImplementation(); + } + + if (trim($this->list)) { + $arr = explode($this->delimiter, $this->list); + + foreach ($arr as $value) { + $value = trim($value); + $premapped = ''; + if ($mapper !== null) { + $premapped = $value; + $value = $mapper->main($value); + if ($value === null) { + continue; + } + $value = array_shift($value); + } + $this->log("Setting param '$this->param' to value '$value'" . ($premapped ? " (mapped from '$premapped')" : ''), Project::MSG_VERBOSE); + $prop = $callee->createProperty(); + $prop->setOverride(true); + $prop->setName($this->param); + $prop->setValue($value); + $callee->main(); + } + } + + // filelists + foreach ($this->filelists as $fl) { + $srcFiles = $fl->getFiles($this->project); + + $this->process($callee, $fl->getDir($this->project), $srcFiles, array()); + } + + // filesets + foreach ($this->filesets as $fs) { + $ds = $fs->getDirectoryScanner($this->project); + $srcFiles = $ds->getIncludedFiles(); + $srcDirs = $ds->getIncludedDirectories(); + + $this->process($callee, $fs->getDir($this->project), $srcFiles, $srcDirs); + } + + $this->log("Processed {$this->total_dirs} directories and {$this->total_files} files", Project::MSG_VERBOSE); + } + + /** + * Processes a list of files & directories + * + * @param Task $callee + * @param PhingFile $fromDir + * @param array $srcFiles + * @param array $srcDirs + */ + protected function process(Task $callee, PhingFile $fromDir, $srcFiles, $srcDirs) + { + $mapper = null; - $arr = explode($this->delimiter, $this->list); + if ($this->mapperElement !== null) { + $mapper = $this->mapperElement->getImplementation(); + } + + $filecount = count($srcFiles); + $this->total_files += $filecount; + + for ($j = 0; $j < $filecount; $j++) { + $value = $srcFiles[$j]; + $premapped = ""; + + if ($this->absparam) { + $prop = $callee->createProperty(); + $prop->setOverride(true); + $prop->setName($this->absparam); + $prop->setValue($fromDir . FileSystem::getFileSystem()->getSeparator() . $value); + } + + if ($mapper !== null) { + $premapped = $value; + $value = $mapper->main($value); + if ($value === null) { + continue; + } + $value = array_shift($value); + } + + if ($this->param) { + $this->log("Setting param '$this->param' to value '$value'" . ($premapped ? " (mapped from '$premapped')" : ''), Project::MSG_VERBOSE); + $prop = $callee->createProperty(); + $prop->setOverride(true); + $prop->setName($this->param); + $prop->setValue($value); + } + + $callee->main(); + } + + $dircount = count($srcDirs); + $this->total_dirs += $dircount; - foreach ($arr as $value) { - $this->log("Setting param '$this->param' to value '$value'", PROJECT_MSG_VERBOSE); - $prop = $callee->createProperty(); - $prop->setOverride(true); - $prop->setName($this->param); - $prop->setValue($value); + for ($j = 0; $j < $dircount; $j++) { + $value = $srcDirs[$j]; + $premapped = ""; + + if ($this->absparam) { + $prop = $callee->createProperty(); + $prop->setOverride(true); + $prop->setName($this->absparam); + $prop->setValue($fromDir . FileSystem::getFileSystem()->getSeparator() . $value); + } + + if ($mapper !== null) { + $premapped = $value; + $value = $mapper->main($value); + if ($value === null) { + continue; + } + $value = array_shift($value); + } + + if ($this->param) { + $this->log("Setting param '$this->param' to value '$value'" . ($premapped ? " (mapped from '$premapped')" : ''), Project::MSG_VERBOSE); + $prop = $callee->createProperty(); + $prop->setOverride(true); + $prop->setName($this->param); + $prop->setValue($value); + } + $callee->main(); } } @@ -124,15 +271,50 @@ class ForeachTask extends Task { $this->param = (string) $param; } + function setAbsparam($absparam) { + $this->absparam = (string) $absparam; + } + function setDelimiter($delimiter) { $this->delimiter = (string) $delimiter; } /** + * Nested creator, adds a set of files (nested fileset attribute). + */ + function createFileSet() { + $num = array_push($this->filesets, new FileSet()); + return $this->filesets[$num-1]; + } + + /** + * Nested creator, creates one Mapper for this task + * + * @access public + * @return object The created Mapper type object + * @throws BuildException + */ + function createMapper() { + if ($this->mapperElement !== null) { + throw new BuildException("Cannot define more than one mapper", $this->location); + } + $this->mapperElement = new Mapper($this->project); + return $this->mapperElement; + } + + /** * @return Property */ function createProperty() { return $this->callee->createProperty(); } + /** + * Supports embedded <filelist> element. + * @return FileList + */ + public function createFileList() { + $num = array_push($this->filelists, new FileList()); + return $this->filelists[$num-1]; + } } diff --git a/buildscripts/phing/classes/phing/tasks/system/IfTask.php b/buildscripts/phing/classes/phing/tasks/system/IfTask.php index ab773355..cff06ce1 100644 --- a/buildscripts/phing/classes/phing/tasks/system/IfTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/IfTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: IfTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 4452f066ac71d51d3e2521d39cdee2caf4f7e9cc $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -67,7 +67,7 @@ require_once 'phing/tasks/system/SequentialTask.php'; * task before you use it the first time:</p> * * <pre><code> - * <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" /> + * <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" /> * </code></pre> * * <h3>Crude Example</h3> @@ -105,6 +105,7 @@ require_once 'phing/tasks/system/SequentialTask.php'; * </code> * * @author <a href="mailto:stefan.bodewig@freenet.de">Stefan Bodewig</a> + * @package phing.tasks.system */ class IfTask extends ConditionBase { @@ -148,16 +149,16 @@ class IfTask extends ConditionBase { } public function main() { - + if ($this->countConditions() > 1) { throw new BuildException("You must not nest more than one condition into <if>"); } if ($this->countConditions() < 1) { throw new BuildException("You must nest a condition into <if>"); } - $conditions = $this->getConditions(); - $c = $conditions[0]; - + $conditions = $this->getConditions(); + $c = $conditions[0]; + if ($c->evaluate()) { if ($this->thenTasks != null) { $this->thenTasks->main(); @@ -165,8 +166,8 @@ class IfTask extends ConditionBase { } else { $done = false; $sz = count($this->elseIfTasks); - for($i=0; $i < $sz && !$done; $i++) { - $ei = $this->elseIfTasks[$i]; + for($i=0; $i < $sz && !$done; $i++) { + $ei = $this->elseIfTasks[$i]; if ($ei->evaluate()) { $done = true; $ei->main(); @@ -183,6 +184,8 @@ class IfTask extends ConditionBase { /** * "Inner" class for IfTask. * This class has same basic structure as the IfTask, although of course it doesn't support <else> tags. + * + * @package phing.tasks.system */ class ElseIfTask extends ConditionBase { @@ -194,31 +197,31 @@ class ElseIfTask extends ConditionBase { } $this->thenTasks = $t; } - - /** - * @return boolean - */ + + /** + * @return boolean + */ public function evaluate() { - + if ($this->countConditions() > 1) { throw new BuildException("You must not nest more than one condition into <elseif>"); } if ($this->countConditions() < 1) { throw new BuildException("You must nest a condition into <elseif>"); } - - $conditions = $this->getConditions(); - $c = $conditions[0]; + + $conditions = $this->getConditions(); + $c = $conditions[0]; return $c->evaluate(); } - - /** - * - */ + + /** + * + */ public function main() { if ($this->thenTasks != null) { $this->thenTasks->main(); } } - }
\ No newline at end of file + } diff --git a/buildscripts/phing/classes/phing/tasks/system/ImportTask.php b/buildscripts/phing/classes/phing/tasks/system/ImportTask.php new file mode 100755 index 00000000..760380eb --- /dev/null +++ b/buildscripts/phing/classes/phing/tasks/system/ImportTask.php @@ -0,0 +1,136 @@ +<?php +/* + * $Id: 88eafadfcd59c0ce28f122926b7d5706b807a8e3 $ + * + * 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/Task.php'; +require_once 'phing/system/io/FileSystem.php'; +require_once 'phing/system/io/PhingFile.php'; +require_once 'phing/parser/ProjectConfigurator.php'; + +/** + * Imports another build file into the current project. + * + * Targets and properties of the imported file can be overrridden + * by targets and properties of the same name declared in the importing file. + * + * The imported file will have a new synthetic property of + * "phing.file.<projectname>" declared which gives the full path to the + * imported file. Additionally each target in the imported file will be + * declared twice: once with the normal name and once with "<projectname>." + * prepended. The "<projectname>.<targetname>" synthetic targets allow the + * importing file a mechanism to call the imported files targets as + * dependencies or via the <phing> or <phingcall> task mechanisms. + * + * @author Bryan Davis <bpd@keynetics.com> + * @version $Id: 88eafadfcd59c0ce28f122926b7d5706b807a8e3 $ + * @package phing.tasks.system + */ +class ImportTask extends Task { + + /** + * @var FileSystem + */ + protected $fs; + + /** + * @var PhingFile + */ + protected $file = null; + + /** + * @var bool + */ + protected $optional = false; + + /** + * Initialize task. + * @return void + */ + public function init () { + $this->fs = FileSystem::getFileSystem(); + } //end init + + + /** + * Set the file to import. + * @param string $f Path to file + * @return void + */ + public function setFile ($f) { + $this->file = $f; + } + + /** + * Is this include optional? + * @param bool $opt If true, do not stop the build if the file does not + * exist + * @return void + */ + public function setOptional ($opt) { + $this->optional = $opt; + } + + /** + * Parse a Phing build file and copy the properties, tasks, data types and + * targets it defines into the current project. + * + * @return void + */ + public function main () { + if (!isset($this->file)) { + throw new BuildException("Missing attribute 'file'"); + } + + $file = new PhingFile($this->file); + if (!$file->isAbsolute()) { + $file = new PhingFile($this->project->getBasedir(), $this->file); + } + if (!$file->exists()) { + $msg = "Unable to find build file: {$file->getPath()}"; + if ($this->optional) { + $this->log($msg . '... skipped'); + return; + } else { + throw new BuildException($msg); + } + } + + $ctx = $this->project->getReference("phing.parsing.context"); + $cfg = $ctx->getConfigurator(); + if (null !== $cfg && $cfg->isParsing()) { + // because there isn't a top level implicit target in phing like there is + // in Ant 1.6, we will be called as soon as our xml is parsed. This isn't + // really what we want to have happen. Instead we will register ourself + // with the parse context to be called at the end of the current file's + // parse phase. + $cfg->delayTaskUntilParseEnd($this); + + } else { + // Import xml file into current project scope + // Since this is delayed until after the importing file has been + // processed, the properties and targets of this new file may not take + // effect if they have alreday been defined in the outer scope. + $this->log("Importing configuration from {$file->getName()}", Project::MSG_VERBOSE); + ProjectConfigurator::configureProject($this->project, $file); + $this->log("Configuration imported.", Project::MSG_VERBOSE); + } + } //end main + +} //end ImportTask diff --git a/buildscripts/phing/classes/phing/tasks/system/IncludePathTask.php b/buildscripts/phing/classes/phing/tasks/system/IncludePathTask.php index ce9beee5..807a3cad 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/IncludePathTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/IncludePathTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: IncludePathTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: eaa0d6c5c7fb908d419cd6e22c7eccbf01506da7 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,7 +34,7 @@ include_once 'phing/types/Path.php'; * </code> * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.1 $ + * @version $Id$ * @package phing.tasks.system */ class IncludePathTask extends Task { @@ -107,7 +107,7 @@ class IncludePathTask extends Task { $new_parts = array_diff($add_parts, $curr_parts); if ($new_parts) { - $this->log("Prepending new include_path components: " . implode(PATH_SEPARATOR, $new_parts), PROJECT_MSG_VERBOSE); + $this->log("Prepending new include_path components: " . implode(PATH_SEPARATOR, $new_parts), Project::MSG_VERBOSE); set_include_path(implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts))); } diff --git a/buildscripts/phing/classes/phing/tasks/system/InputTask.php b/buildscripts/phing/classes/phing/tasks/system/InputTask.php index a5e1fdb9..3c7168fd 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/InputTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/InputTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: InputTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: ae986f84ca9d952b0e14f2df9f21657213ef5e47 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,7 +31,7 @@ include_once 'phing/input/MultipleChoiceInputRequest.php'; * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Ulrich Schmidt <usch@usch.net> (Ant) * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant) - * @version $Revision: 1.6 $ + * @version $Id: ae986f84ca9d952b0e14f2df9f21657213ef5e47 $ * @package phing.tasks.system */ class InputTask extends Task { @@ -104,6 +104,10 @@ class InputTask extends Task { throw new BuildException("You must specify a value for propertyName attribute."); } + if ($this->message === "") { + throw new BuildException("You must specify a message for input task."); + } + if ($this->validargs !== null) { $accept = preg_split('/[\s,]+/', $this->validargs); diff --git a/buildscripts/phing/classes/phing/tasks/system/LoadFileTask.php b/buildscripts/phing/classes/phing/tasks/system/LoadFileTask.php new file mode 100644 index 00000000..ff7b7d3b --- /dev/null +++ b/buildscripts/phing/classes/phing/tasks/system/LoadFileTask.php @@ -0,0 +1,119 @@ +<?php +/* + * $Id: d4796a6eb57300eca59f8b6f79e3dbcb08d1e346 $ + * + * 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/Task.php'; + +/** + * LoadFileTask + * + * Loads a (text) file and stores the contents in a property. + * Supports filterchains. + * + * @author Michiel Rook <mrook@php.net> + * @version $Id: d4796a6eb57300eca59f8b6f79e3dbcb08d1e346 $ + * @package phing.tasks.ext + */ +class LoadFileTask extends Task +{ + /** + * File to read + * @var PhingFile file + */ + private $file; + + /** + * Property to be set + * @var string $property + */ + private $property; + + /** + * Array of FilterChain objects + * @var FilterChain[] + */ + private $filterChains = array(); + + /** + * Set file to read + * @param PhingFile $file + */ + public function setFile($file) + { + $this->file = $file; + } + + /** + * Convenience setter to maintain Ant compatibility (@see setFile()) + * @param PhingFile $file + */ + public function setSrcFile($srcFile) + { + $this->file = $srcFile; + } + + /** + * Set name of property to be set + * @param $property + * @return void + */ + public function setProperty($property) + { + $this->property = $property; + } + + /** + * Creates a filterchain + * + * @return object The created filterchain object + */ + function createFilterChain() { + $num = array_push($this->filterChains, new FilterChain($this->project)); + return $this->filterChains[$num-1]; + } + + /** + * Main method + * + * @return void + * @throws BuildException + */ + public function main() + { + if (empty($this->file)) { + throw new BuildException("Attribute 'file' required", $this->getLocation()); + } + + if (empty($this->property)) { + throw new BuildException("Attribute 'property' required", $this->getLocation()); + } + + // read file (through filterchains) + $contents = ""; + + $reader = FileUtils::getChainedReader(new FileReader($this->file), $this->filterChains, $this->project); + while(-1 !== ($buffer = $reader->read())) { + $contents .= $buffer; + } + $reader->close(); + + // publish as property + $this->project->setProperty($this->property, $contents); + } +}
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/system/MatchingTask.php b/buildscripts/phing/classes/phing/tasks/system/MatchingTask.php index c5497fbd..b04be2e1 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/MatchingTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/MatchingTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: MatchingTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 1e1f6274f400b90c2344c8cdb5d3711030b8f44a $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -38,7 +38,7 @@ include_once 'phing/util/DirectoryScanner.php'; * @author Jon S. Stevens <jon@clearink.com> (Ant * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant) * @author Bruce Atherton <bruce@callenish.com> (Ant) - * @version $Revision: 1.4 $ + * @version $Id: 1e1f6274f400b90c2344c8cdb5d3711030b8f44a $ * @package phing.tasks.system */ abstract class MatchingTask extends Task implements SelectorContainer { @@ -59,7 +59,7 @@ abstract class MatchingTask extends Task implements SelectorContainer { /** * @see ProjectComponent::setProject() */ - public function setProject(Project $project) { + public function setProject($project) { parent::setProject($project); $this->fileset->setProject($project); } diff --git a/buildscripts/phing/classes/phing/tasks/system/MkdirTask.php b/buildscripts/phing/classes/phing/tasks/system/MkdirTask.php index 9d5c1f31..934b991f 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/MkdirTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/MkdirTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: MkdirTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: e7e3dbd896d8d46cd8694fca10d1d9a7b3ce54fc $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -26,13 +26,19 @@ include_once 'phing/system/io/PhingFile.php'; * Task to create a directory. * * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.8 $ + * @version $Id$ * @package phing.tasks.system */ class MkdirTask extends Task { /** directory to create*/ private $dir; + + /** + * Mode to create directory with + * @var integer + */ + private $mode = 0755; /** * create the directory and all parents @@ -47,7 +53,7 @@ class MkdirTask extends Task { throw new BuildException("Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath()); } if (!$this->dir->exists()) { - $result = $this->dir->mkdirs(); + $result = $this->dir->mkdirs($this->mode); if (!$result) { $msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason"; throw new BuildException($msg, $this->location); @@ -60,5 +66,14 @@ class MkdirTask extends Task { function setDir(PhingFile $dir) { $this->dir = $dir; } + + /** + * Sets mode to create directory with + * @param mixed $mode + */ + function setMode($mode) + { + $this->mode = base_convert((int) $mode, 8, 10); + } } diff --git a/buildscripts/phing/classes/phing/tasks/system/MoveTask.php b/buildscripts/phing/classes/phing/tasks/system/MoveTask.php index a3e94536..e7041464 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/MoveTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/MoveTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: MoveTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 01e6d627d455729bfed47d603188d8c56f54d9e5 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -35,7 +35,7 @@ include_once 'phing/system/io/IOException.php'; * Source files and directories are only deleted when the file or * directory has been copied to the destination successfully. * - * @version $Revision: 1.8 $ + * @version $Id$ * @package phing.tasks.system */ class MoveTask extends CopyTask { @@ -45,7 +45,58 @@ class MoveTask extends CopyTask { $this->forceOverwrite = true; } + /** + * Validates attributes coming in from XML + * + * @access private + * @return void + * @throws BuildException + */ + protected function validateAttributes() { + if ($this->file !== null && $this->file->isDirectory()) { + if (($this->destFile !== null && $this->destDir !== null) + || ($this->destFile === null && $this->destDir === null)) { + throw new BuildException("One and only one of tofile and todir must be set."); + } + + if ($this->destFile === null) + { + $this->destFile = new PhingFile($this->destDir, $this->file->getName()); + } + + if ($this->destDir === null) + { + $this->destDir = $this->destFile->getParentFile(); + } + + $this->completeDirMap[$this->file->getAbsolutePath()] = $this->destFile->getAbsolutePath(); + + $this->file = null; + } else { + parent::validateAttributes(); + } + } + protected function doWork() { + if (count($this->completeDirMap) > 0) + { + foreach ($this->completeDirMap as $from => $to) + { + $f = new PhingFile($from); + $d = new PhingFile($to); + + $moved = false; + try { // try to rename + $this->log("Attempting to rename $from to $to", $this->verbosity); + $this->fileUtils->copyFile($f, $d, $this->forceOverwrite, $this->preserveLMT, $this->filterChains, $this->getProject(), $this->mode); + $f->delete(true); + $moved = true; + } catch (IOException $ioe) { + $moved = false; + $this->logError("Failed to rename $from to $to: " . $ioe->getMessage()); + } + } + } $copyMapSize = count($this->fileCopyMap); if ($copyMapSize > 0) { @@ -58,33 +109,18 @@ class MoveTask extends CopyTask { continue; } - $moved = false; $f = new PhingFile($from); $d = new PhingFile($to); - $moved = false; - try { // try to rename - $this->log("Attempting to rename $from to $to", $this->verbosity); - $this->renameFile($f, $d, $this->forceOverwrite); - $moved = true; - } catch (IOException $ioe) { - $moved = false; - $this->log("Failed to rename $from to $to: " . $ioe->getMessage(), $this->verbosity); - } - - if (!$moved) { - try { // try to move - $this->log("Moving $from to $to", $this->verbosity); + try { // try to move + $this->log("Moving $from to $to", $this->verbosity); - $this->fileUtils->copyFile($f, $d, $this->forceOverwrite, $this->preserveLMT, $this->filterChains, $this->getProject()); + $this->fileUtils->copyFile($f, $d, $this->forceOverwrite, $this->preserveLMT, $this->filterChains, $this->getProject(), $this->mode); - $f = new PhingFile($fromFile); - $f->delete(); - } catch (IOException $ioe) { - $msg = "Failed to move $from to $to: " . $ioe->getMessage(); - throw new BuildException($msg, $this->location); - } - } // if !moved + $f->delete(); + } catch (IOException $ioe) { + $this->logError("Failed to move $from to $to: " . $ioe->getMessage(), $this->location); + } } // foreach fileCopyMap } // if copyMapSize @@ -96,7 +132,7 @@ class MoveTask extends CopyTask { $d = new PhingFile((string) $dir); if (!$d->exists()) { if (!$d->mkdirs()) { - $this->log("Unable to create directory " . $d->getAbsolutePath(), PROJECT_MSG_ERR); + $this->logError("Unable to create directory " . $d->getAbsolutePath()); } else { $count++; } @@ -160,38 +196,7 @@ class MoveTask extends CopyTask { try { $d->delete(); } catch (Exception $e) { - throw new BuildException("Unable to delete directory " . $d->__toString() . ": " . $e->getMessage()); + $this->logError("Unable to delete directory " . $d->__toString() . ": " . $e->getMessage()); } } - - /** - * Attempts to rename a file from a source to a destination. - * If overwrite is set to true, this method overwrites existing file - * even if the destination file is newer. - * Otherwise, the source f - * ile is renamed only if the destination file # - * is older than it. - */ - private function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite) { - $renamed = true; - - // ensure that parent dir of dest file exists! - $parent = $destFile->getParentFile(); - if ($parent !== null) { - if (!$parent->exists()) { - $parent->mkdirs(); - } - } - if ($destFile->exists()) { - try { - $destFile->delete(); - } catch (Exception $e) { - throw new BuildException("Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage()); - } - } - $renamed = $sourceFile->renameTo($destFile); - - return $renamed; - } } -?> diff --git a/buildscripts/phing/classes/phing/tasks/system/PhingCallTask.php b/buildscripts/phing/classes/phing/tasks/system/PhingCallTask.php index 34d4336d..2aec4db5 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/PhingCallTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/PhingCallTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: PhingCallTask.php 59 2006-04-28 14:49:47Z mrook $ - * + * $Id: 5d02fa25dc18b56093884ae756b1720aafb42937 $ + * * 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 @@ -24,7 +24,7 @@ require_once 'phing/Task.php'; /** * Call another target in the same project. * - * <pre> + * <samp> * <target name="foo"> * <phingcall target="bar"> * <property name="property1" value="aaaaa" /> @@ -35,24 +35,44 @@ require_once 'phing/Task.php'; * <target name="bar" depends="init"> * <echo message="prop is ${property1} ${foo}" /> * </target> - * </pre> + * </samp> * - * <p>This only works as expected if neither property1 nor foo are - * defined in the project itself. + * This only works as expected if neither property1 nor foo are defined in the project itself. * * @author Andreas Aderhold <andi@binarycloud.com> * @copyright 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.9 $ + * @version $Id: 5d02fa25dc18b56093884ae756b1720aafb42937 $ * @access public * @package phing.tasks.system */ class PhingCallTask extends Task { + /** + * The called Phing task. + * + * @var PhingTask + */ private $callee; + + /** + * The target to call. + * + * @var string + */ private $subTarget; - // must match the default value of PhingTask#inheritAll + + /** + * Whether to inherit all properties from current project. + * + * @var boolean + */ private $inheritAll = true; - // must match the default value of PhingTask#inheritRefs + + /** + * Whether to inherit refs from current project. + * + * @var boolean + */ private $inheritRefs = false; /** @@ -67,7 +87,7 @@ class PhingCallTask extends Task { /** * If true, pass all references to the new Phing project. * Defaults to false. Future use. - * + * * @param boolean new value */ function setInheritRefs($inheritRefs) { @@ -75,6 +95,34 @@ class PhingCallTask extends Task { } /** + * Alias for createProperty + * @see createProperty() + */ + function createParam() { + if ($this->callee === null) { + $this->init(); + } + return $this->callee->createProperty(); + } + + /** + * Property to pass to the invoked target. + */ + function createProperty() { + if ($this->callee === null) { + $this->init(); + } + return $this->callee->createProperty(); + } + + /** + * Target to execute, required. + */ + function setTarget($target) { + $this->subTarget = (string) $target; + } + + /** * init this task by creating new instance of the phing task and * configuring it's by calling its own init method. */ @@ -82,6 +130,7 @@ class PhingCallTask extends Task { $this->callee = $this->project->createTask("phing"); $this->callee->setOwningTarget($this->getOwningTarget()); $this->callee->setTaskName($this->getTaskName()); + $this->callee->setHaltOnFailure(true); $this->callee->setLocation($this->getLocation()); $this->callee->init(); } @@ -91,17 +140,17 @@ class PhingCallTask extends Task { * @throws BuildException on validation failure or if the target didn't * execute */ - function main() { - - $this->log("Running PhingCallTask for target '" . $this->subTarget . "'", PROJECT_MSG_DEBUG); + function main() { + + $this->log("Running PhingCallTask for target '" . $this->subTarget . "'", Project::MSG_DEBUG); if ($this->callee === null) { $this->init(); } if ($this->subTarget === null) { - throw new BuildException("Attribute target is required.", $this->location); + throw new BuildException("Attribute target is required.", $this->getLocation()); } - + $this->callee->setPhingfile($this->project->getProperty("phing.file")); $this->callee->setTarget($this->subTarget); $this->callee->setInheritAll($this->inheritAll); @@ -109,31 +158,4 @@ class PhingCallTask extends Task { $this->callee->main(); } - /** - * Alias for createProperty - * @see createProperty() - */ - function createParam() { - if ($this->callee === null) { - $this->init(); - } - return $this->callee->createProperty(); - } - - /** - * Property to pass to the invoked target. - */ - function createProperty() { - if ($this->callee === null) { - $this->init(); - } - return $this->callee->createProperty(); - } - - /** - * Target to execute, required. - */ - function setTarget($target) { - $this->subTarget = (string) $target; - } } diff --git a/buildscripts/phing/classes/phing/tasks/system/PhingTask.php b/buildscripts/phing/classes/phing/tasks/system/PhingTask.php index e9883dd7..6ac0b5ac 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/PhingTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/PhingTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: PhingTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 2eec26f6ebaaeceb4eca76644de88bde7515f5dc $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -41,7 +41,7 @@ include_once 'phing/tasks/system/PropertyTask.php'; * </pre> * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.20 $ + * @version $Id: 2eec26f6ebaaeceb4eca76644de88bde7515f5dc $ * @package phing.tasks.system */ class PhingTask extends Task { @@ -151,46 +151,47 @@ class PhingTask extends Task { } // if no filesets are given stop here; else process filesets - if (empty($this->filesets)) { - return; - } - - // preserve old settings - $savedDir = $this->dir; - $savedPhingFile = $this->phingFile; - $savedTarget = $this->newTarget; - $buildFailed = false; - - // set no specific target for files in filesets - // [HL] I'm commenting this out; I don't know why this should not be supported! - // $this->newTarget = null; - - foreach($this->filesets as $fs) { - - $ds = $fs->getDirectoryScanner($this->project); - - $fromDir = $fs->getDir($this->project); - $srcFiles = $ds->getIncludedFiles(); - - foreach($srcFiles as $fname) { - $f = new PhingFile($ds->getbasedir(), $fname); - $f = $f->getAbsoluteFile(); - $this->phingFile = $f->getAbsolutePath(); - $this->dir = $f->getParentFile(); - $this->processFile(); // run Phing! + if (!empty($this->filesets)) { + // preserve old settings + $savedDir = $this->dir; + $savedPhingFile = $this->phingFile; + $savedTarget = $this->newTarget; + + // set no specific target for files in filesets + // [HL] I'm commenting this out; I don't know why this should not be supported! + // $this->newTarget = null; + + foreach($this->filesets as $fs) { + + $ds = $fs->getDirectoryScanner($this->project); + + $fromDir = $fs->getDir($this->project); + $srcFiles = $ds->getIncludedFiles(); + + foreach($srcFiles as $fname) { + $f = new PhingFile($ds->getbasedir(), $fname); + $f = $f->getAbsoluteFile(); + $this->phingFile = $f->getAbsolutePath(); + $this->dir = $f->getParentFile(); + $this->processFile(); // run Phing! + } + } + + // side effect free programming ;-) + $this->dir = $savedDir; + $this->phingFile = $savedPhingFile; + $this->newTarget = $savedTarget; + + // [HL] change back to correct dir + if ($this->dir !== null) { + chdir($this->dir->getAbsolutePath()); } - } - - // side effect free programming ;-) - $this->dir = $savedDir; - $this->phingFile = $savedPhingFile; - $this->newTarget = $savedTarget; - - // [HL] change back to correct dir - if ($this->dir !== null) { - chdir($this->dir->getAbsolutePath()); } + // Remove any dangling references to help the GC + foreach ($this->properties as $property) { + $property->setFallback(null); + } } /** @@ -199,27 +200,49 @@ class PhingTask extends Task { * @return void */ private function processFile() { - + + $buildFailed = false; $savedDir = $this->dir; $savedPhingFile = $this->phingFile; $savedTarget = $this->newTarget; + $savedBasedirAbsPath = null; // this is used to save the basedir *if* we change it + try { + if ($this->newProject === null) { $this->reinit(); } - if (($this->dir === null) && ($this->inheritAll)) { - $this->dir = $this->getProject()->getBaseDir(); - } $this->initializeProject(); + if ($this->dir !== null) { - $this->newProject->setBaseDir($this->dir); + + $dirAbsPath = $this->dir->getAbsolutePath(); + + // BE CAREFUL! -- when the basedir is changed for a project, + // all calls to getAbsolutePath() on a relative-path dir will + // be made relative to the project's basedir! This means + // that subsequent calls to $this->dir->getAbsolutePath() will be WRONG! + + // We need to save the current project's basedir first. + $savedBasedirAbsPath = $this->getProject()->getBasedir()->getAbsolutePath(); + + $this->newProject->setBasedir($this->dir); + + // Now we must reset $this->dir so that it continues to resolve to the same + // path. + $this->dir = new PhingFile($dirAbsPath); + if ($savedDir !== null) { // has been set explicitly $this->newProject->setInheritedProperty("project.basedir", $this->dir->getAbsolutePath()); - } + } + } else { - $this->dir = $this->getProject()->getBaseDir(); + + // Since we're not changing the basedir here (for file resolution), + // we don't need to worry about any side-effects in this scanrio. + $this->dir = $this->getProject()->getBasedir(); } $this->overrideProperties(); @@ -255,31 +278,37 @@ class PhingTask extends Task { } catch (Exception $e) { $buildFailed = true; - $this->log($e->getMessage(), PROJECT_MSG_ERR); - - // important!!! continue on to perform cleanup - // tasks. - } + $this->log($e->getMessage(), Project::MSG_ERR); + if (Phing::getMsgOutputLevel() <= Project::MSG_DEBUG) { + $lines = explode("\n", $e->getTraceAsString()); + foreach($lines as $line) { + $this->log($line, Project::MSG_DEBUG); + } + } + // important!!! continue on to perform cleanup tasks. + } + + + // reset environment values to prevent side-effects. - // } finally { - // restore values (prevent side-effects) - // !this must match code in catch () {} block! $this->newProject = null; $pkeys = array_keys($this->properties); foreach($pkeys as $k) { $this->properties[$k]->setProject(null); - } + } + $this->dir = $savedDir; $this->phingFile = $savedPhingFile; $this->newTarget = $savedTarget; - // [HL] change back to correct dir - if ($this->dir !== null) { - chdir($this->dir->getAbsolutePath()); + // If the basedir for any project was changed, we need to set that back here. + if ($savedBasedirAbsPath !== null) { + chdir($savedBasedirAbsPath); } - if ($this->haltOnFailure == true && $buildFailed == true) + if ($this->haltOnFailure && $buildFailed) { throw new BuildException("Execution of the target buildfile failed. Aborting."); + } } /** @@ -392,7 +421,7 @@ class PhingTask extends Task { if (!isset($projReferences[$refid])) { $this->log("Parent project doesn't contain any reference '" . $refid . "'", - PROJECT_MSG_WARN); + Project::MSG_WARN); continue; } @@ -449,8 +478,8 @@ class PhingTask extends Task { $copy->setProject($this->newProject); } elseif (in_array('setProject', get_class_methods(get_class($copy)))) { $copy->setProject($this->newProject); - } elseif ($copy instanceof Project) { - // don't copy the old "Project" itself + } elseif ($copy instanceof Project) { + // don't copy the old "Project" itself } else { $msg = "Error setting new project instance for " . "reference with id " . $oldKey; @@ -569,6 +598,8 @@ class PhingTask extends Task { /** * Helper class that implements the nested <reference> * element of <phing> and <phingcall>. + * + * @package phing.tasks.system */ class PhingReference extends Reference { diff --git a/buildscripts/phing/classes/phing/tasks/system/PhpEvalTask.php b/buildscripts/phing/classes/phing/tasks/system/PhpEvalTask.php index f1b72815..99316f7b 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/PhpEvalTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/PhpEvalTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: PhpEvalTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 8c46403ac685f362e310ffcceff5d4193bf09ef0 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,7 +29,7 @@ require_once 'phing/Task.php'; * modify internal Phing classes unless you know what you are doing. * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.7 $ + * @version $Id$ * @package phing.tasks.system * * @todo Add support for evaluating expressions @@ -39,9 +39,27 @@ class PhpEvalTask extends Task { protected $expression; // Expression to evaluate protected $function; // Function to execute protected $class; // Class containing function to execute - protected $returnProperty; // name of property to set to return value + protected $returnProperty = null; // name of property to set to return value protected $params = array(); // parameters for function calls + protected $logLevel = Project::MSG_INFO; + + /** + * Set level of log messages generated (default = info) + * @param string $level + */ + public function setLevel($level) + { + switch ($level) + { + case "error": $this->logLevel = Project::MSG_ERR; break; + case "warning": $this->logLevel = Project::MSG_WARN; break; + case "info": $this->logLevel = Project::MSG_INFO; break; + case "verbose": $this->logLevel = Project::MSG_VERBOSE; break; + case "debug": $this->logLevel = Project::MSG_DEBUG; break; + } + } + /** Main entry point. */ function main() { @@ -57,15 +75,10 @@ class PhpEvalTask extends Task { throw new BuildException("You cannot use nested <param> tags when evaluationg a PHP expression.", $this->location); } - $retval = null; if ($this->function !== null) { - $retval = $this->callFunction(); + $this->callFunction(); } elseif ($this->expression !== null) { - $retval = $this->evalExpression(); - } - - if ($this->returnProperty !== null) { - $this->project->setProperty($this->returnProperty, $retval); + $this->evalExpression(); } } @@ -92,13 +105,16 @@ class PhpEvalTask extends Task { $params[] = $p->getValue(); } - $this->log("Calling PHP function: " . $h_func . "()"); + $this->log("Calling PHP function: " . $h_func . "()", $this->logLevel); foreach($params as $p) { - $this->log(" param: " . $p, PROJECT_MSG_VERBOSE); + $this->log(" param: " . $p, Project::MSG_VERBOSE); } $return = call_user_func_array($user_func, $params); - return $return; + + if ($this->returnProperty !== null) { + $this->project->setProperty($this->returnProperty, $return); + } } /** @@ -106,13 +122,18 @@ class PhpEvalTask extends Task { * @return mixed */ protected function evalExpression() { - $this->log("Evaluating PHP expression: " . $this->expression); + $this->log("Evaluating PHP expression: " . $this->expression, $this->logLevel); if (!StringHelper::endsWith(';', trim($this->expression))) { $this->expression .= ';'; } - $retval = null; - eval('$retval = ' . $this->expression); - return $retval; + + if ($this->returnProperty !== null) { + $retval = null; + eval('$retval = ' . $this->expression); + $this->project->setProperty($this->returnProperty, $retval); + } else { + eval($this->expression); + } } /** Set function to execute */ @@ -150,6 +171,8 @@ class PhpEvalTask extends Task { /** * Supports the <param> nested tag for PhpTask. + * + * @package phing.tasks.system */ class FunctionParam { diff --git a/buildscripts/phing/classes/phing/tasks/system/PropertyPromptTask.php b/buildscripts/phing/classes/phing/tasks/system/PropertyPromptTask.php index e7e12f33..7a337764 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/PropertyPromptTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/PropertyPromptTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: PropertyPromptTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: d2de9371732599b179facb97ef937b2cfbfbead2 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,39 +31,63 @@ include_once 'phing/system/io/ConsoleReader.php'; * * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Anthony J. Young-Garner <ajyoung@alum.mit.edu> (Ant) - * @version $Revision: 1.4 $ + * @version $Id$ * @package phing.tasks.system * @deprecated - in favor of the more capable InputTask */ class PropertyPromptTask extends Task { - + + /** + * The property name to set with the output. + * @var string + */ private $propertyName; // required + + /** + * The default value to use if no input is entered. + * @var string + */ private $defaultValue; - private $proposedValue; // required - private $promptText; // required + + /** + * The entered value. + * @var string + */ + private $proposedValue; + + /** + * The text to use for the prompt. + * @var string + */ + private $promptText; + + /** + * The character to put after the text. + * @var string + */ private $promptCharacter; - private $useExistingValue; - + /** - * Sets the prompt text that will be presented to the user. - * @param string $prompt - * @return void + * */ - public function addText($prompt) { - $this->setPromptText($prompt); - } + private $useExistingValue; /** * Run the PropertyPrompt task. * @throws BuildException */ public function main() { + $this->proposedValue = $this->project->getProperty($this->propertyName); $currentValue = $this->defaultValue; - if ($currentValue == "" && $this->proposedValue !== null) { $currentValue = $this->proposedValue; } - if (! (($this->useExistingValue === true) && ($this->proposedValue !== null))) { + + if ($currentValue == "" && $this->proposedValue !== null) { + $currentValue = $this->proposedValue; + } + + if ($this->useExistingValue !== true || $this->proposedValue === null) { - $this->log("Prompting user for " . $this->propertyName . ". " . $this->getDefaultMessage(), PROJECT_MSG_VERBOSE); + $this->log("Prompting user for " . $this->propertyName . ". " . $this->getDefaultMessage(), Project::MSG_VERBOSE); print "\n" . $this->promptText . " [" . $currentValue . "] " . $this->promptCharacter . " "; @@ -77,12 +101,12 @@ class PropertyPromptTask extends Task { $this->proposedValue = $this->defaultValue; } - if (empty($this->proposedValue)) { - $this->log("No value specified, using default.", PROJECT_MSG_VERBOSE); + if ($this->proposedValue === "") { + $this->log("No value specified, using default.", Project::MSG_VERBOSE); $this->proposedValue = $this->defaultValue; } - if (!empty($this->proposedValue)) { + if (isset($this->proposedValue)) { $this->project->setProperty($this->propertyName, $this->proposedValue); } @@ -166,7 +190,7 @@ class PropertyPromptTask extends Task { /** * Sets the terminating character used to * punctuate the prompt text (default is "?"). - * @param newPromptcharacter java.lang.String + * @param string $newPromptcharacter */ public function setPromptCharacter($newPromptcharacter) { $this->promptCharacter = $newPromptcharacter; @@ -174,7 +198,7 @@ class PropertyPromptTask extends Task { /** * Sets text of the prompt. - * @param newPrompttext java.lang.String + * @param string $newPrompttext */ public function setPromptText($newPrompttext) { $this->promptText = $newPrompttext; @@ -191,11 +215,20 @@ class PropertyPromptTask extends Task { /** * - * - * @param boolean newUseExistingValue + * @param boolean $newUseExistingValue */ public function setUseExistingValue($newUseExistingValue) { $this->useExistingValue = $newUseExistingValue; } + /** + * Sets the prompt text that will be presented to the user. + * @param string $prompt + * @return void + */ + public function addText($prompt) { + $this->setPromptText($prompt); + } + + } diff --git a/buildscripts/phing/classes/phing/tasks/system/PropertyTask.php b/buildscripts/phing/classes/phing/tasks/system/PropertyTask.php index d6168e44..0d8854c8 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/PropertyTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/PropertyTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: PropertyTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: e6d7123b6331d5032ad1e67967cf54ef2aae3f7f $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -28,7 +28,7 @@ include_once 'phing/system/util/Properties.php'; * * @author Andreas Aderhold <andi@binarycloud.com> * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision$ + * @version $Id: e6d7123b6331d5032ad1e67967cf54ef2aae3f7f $ * @package phing.tasks.system */ class PropertyTask extends Task { @@ -71,15 +71,15 @@ class PropertyTask extends Task { function setValue($value) { $this->value = (string) $value; } - - /** - * Sets value of property to CDATA tag contents. - * @param string $values - * @since 2.2.0 - */ - public function addText($value) { - $this->setValue($value); - } + + /** + * Sets value of property to CDATA tag contents. + * @param string $values + * @since 2.2.0 + */ + public function addText($value) { + $this->setValue($value); + } /** Get the value of current property component. */ function getValue() { @@ -182,9 +182,9 @@ class PropertyTask extends Task { return (string) $this->value; } - /** - * @param Project $p - */ + /** + * @param Project $p + */ function setFallback($p) { $this->fallback = $p; } @@ -248,7 +248,7 @@ class PropertyTask extends Task { if ( substr($prefix, strlen($prefix)-1) == '.' ) { $prefix .= "."; } - $this->log("Loading Environment $prefix", PROJECT_MSG_VERBOSE); + $this->log("Loading Environment $prefix", Project::MSG_VERBOSE); foreach($_ENV as $key => $value) { $props->setProperty($prefix . '.' . $key, $value); } @@ -281,7 +281,7 @@ class PropertyTask extends Task { if ($this->project->getUserProperty($name) === null || $this->override) { $this->project->setInheritedProperty($name, $value); } else { - $this->log("Override ignored for " . $name, PROJECT_MSG_VERBOSE); + $this->log("Override ignored for " . $name, Project::MSG_VERBOSE); } } else { if ($this->override) { @@ -298,13 +298,13 @@ class PropertyTask extends Task { */ protected function loadFile(PhingFile $file) { $props = new Properties(); - $this->log("Loading ". $file->getAbsolutePath(), PROJECT_MSG_INFO); + $this->log("Loading ". $file->getAbsolutePath(), Project::MSG_INFO); try { // try to load file if ($file->exists()) { $props->load($file); $this->addProperties($props); } else { - $this->log("Unable to find property file: ". $file->getAbsolutePath() ."... skipped", PROJECT_MSG_WARN); + $this->log("Unable to find property file: ". $file->getAbsolutePath() ."... skipped", Project::MSG_WARN); } } catch (IOException $ioe) { throw new BuildException("Could not load properties from file.", $ioe); @@ -356,7 +356,7 @@ class PropertyTask extends Task { if ($propertyName === $name) { // Should we maybe just log this as an error & move on? - // $this->log("Property ".$name." was circularly defined.", PROJECT_MSG_ERR); + // $this->log("Property ".$name." was circularly defined.", Project::MSG_ERR); throw new BuildException("Property ".$name." was circularly defined."); } @@ -373,7 +373,7 @@ class PropertyTask extends Task { $sb .= $fragment; } - $this->log("Resolved Property \"$value\" to \"$sb\"", PROJECT_MSG_DEBUG); + $this->log("Resolved Property \"$value\" to \"$sb\"", Project::MSG_DEBUG); $value = $sb; $props->setProperty($name, $value); diff --git a/buildscripts/phing/classes/phing/tasks/system/ReflexiveTask.php b/buildscripts/phing/classes/phing/tasks/system/ReflexiveTask.php index dc7cfeb7..d49c47f2 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ReflexiveTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ReflexiveTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ReflexiveTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 3dcb1ad6e9fd3b2801c1fe3bcbaf2fcab8ea6018 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -43,7 +43,7 @@ require_once 'phing/Task.php'; * </code> * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.11 $ + * @version $Id$ * @package phing.tasks.system */ class ReflexiveTask extends Task { @@ -105,24 +105,24 @@ class ReflexiveTask extends Task { $files[] = new PhingFile($dir, $fname); } } catch (BuildException $be) { - $this->log($be->getMessage(), PROJECT_MSG_WARN); + $this->log($be->getMessage(), Project::MSG_WARN); } } } $this->log("Applying reflexive processing to " . count($files) . " files."); - // These "slots" allow filters to retrieve information about the currently-being-process files - $slot = $this->getRegisterSlot("currentFile"); - $basenameSlot = $this->getRegisterSlot("currentFile.basename"); + // These "slots" allow filters to retrieve information about the currently-being-process files + $slot = $this->getRegisterSlot("currentFile"); + $basenameSlot = $this->getRegisterSlot("currentFile.basename"); foreach($files as $file) { - // set the register slots - - $slot->setValue($file->getPath()); - $basenameSlot->setValue($file->getName()); - + // set the register slots + + $slot->setValue($file->getPath()); + $basenameSlot->setValue($file->getName()); + // 1) read contents of file, pulling through any filters $in = null; try { @@ -134,7 +134,7 @@ class ReflexiveTask extends Task { $in->close(); } catch (Exception $e) { if ($in) $in->close(); - $this->log("Erorr reading file: " . $e->getMessage(), PROJECT_MSG_WARN); + $this->log("Erorr reading file: " . $e->getMessage(), Project::MSG_WARN); } try { @@ -142,14 +142,14 @@ class ReflexiveTask extends Task { $out = new FileWriter($file); $out->write($contents); $out->close(); - $this->log("Applying reflexive processing to " . $file->getPath(), PROJECT_MSG_VERBOSE); + $this->log("Applying reflexive processing to " . $file->getPath(), Project::MSG_VERBOSE); } catch (Exception $e) { if ($out) $out->close(); - $this->log("Error writing file back: " . $e->getMessage(), PROJECT_MSG_WARN); + $this->log("Error writing file back: " . $e->getMessage(), Project::MSG_WARN); } } } -}
\ No newline at end of file +} diff --git a/buildscripts/phing/classes/phing/tasks/system/ResolvePathTask.php b/buildscripts/phing/classes/phing/tasks/system/ResolvePathTask.php index b468afb5..bdd707a2 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/ResolvePathTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/ResolvePathTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ResolvePathTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 9635ed3f6605f5ed64b74e85731dbcd3ad43ce0f $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -39,7 +39,7 @@ require_once 'phing/Task.php'; * - Possibly integrate this with PackageAsPath, for handling/resolving dot-path paths. * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.6 $ + * @version $Id$ * @package phing.tasks.system */ class ResolvePathTask extends Task { @@ -54,6 +54,11 @@ class ResolvePathTask extends Task { private $dir; /** + * Log level + */ + private $logLevel = Project::MSG_VERBOSE; + + /** * Set the name of the property to set. * @param string $v Property name * @return void @@ -90,6 +95,38 @@ class ResolvePathTask extends Task { } /** + * Set level of log messages generated (default = verbose) + * + * @param string $level Log level + * + * @return void + */ + public function setLevel($level) + { + switch ($level) { + case 'error': + $this->logLevel = Project::MSG_ERR; + break; + case 'warning': + $this->logLevel = Project::MSG_WARN; + break; + case 'info': + $this->logLevel = Project::MSG_INFO; + break; + case 'verbose': + $this->logLevel = Project::MSG_VERBOSE; + break; + case 'debug': + $this->logLevel = Project::MSG_DEBUG; + break; + default: + throw new BuildException( + sprintf('Unknown log level "%s"', $level) + ); + } + } + + /** * Perform the resolution & set property. */ public function main() { @@ -103,11 +140,11 @@ class ResolvePathTask extends Task { throw new BuildException("You must specify a path to resolve", $this->getLocation()); } - $fs = FileSystem::getFileSystem(); - + $fs = FileSystem::getFileSystem(); + // if dir attribute was specified then we should // use that as basedir to which file was relative. - // -- unless the file specified is an absolute path + // -- unless the file specified is an absolute path if ($this->dir !== null && !$fs->isAbsolute(new PhingFile($this->file))) { $resolved = new PhingFile($this->dir->getPath(), $this->file); } else { @@ -115,7 +152,7 @@ class ResolvePathTask extends Task { $resolved = $this->project->resolveFile($this->file); } - $this->log("Resolved " . $this->file . " to " . $resolved->getAbsolutePath(), PROJECT_MSG_INFO); + $this->log("Resolved " . $this->file . " to " . $resolved->getAbsolutePath(), $this->logLevel); $this->project->setProperty($this->propertyName, $resolved->getAbsolutePath()); } diff --git a/buildscripts/phing/classes/phing/tasks/system/SequentialTask.php b/buildscripts/phing/classes/phing/tasks/system/SequentialTask.php index 50327e3f..d080deda 100644 --- a/buildscripts/phing/classes/phing/tasks/system/SequentialTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/SequentialTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: SequentialTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: e6be0ff54ade0fb900d101759d8788590e769831 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,11 +31,12 @@ require_once 'phing/TaskContainer.php'; * sequential task. * * @since 2.1.2 + * @package phing.tasks.system */ class SequentialTask extends Task implements TaskContainer { /** Optional Vector holding the nested tasks */ - private $nestedTasks = array(); + protected $nestedTasks = array(); /** * Add a nested task to Sequential. @@ -50,8 +51,8 @@ class SequentialTask extends Task implements TaskContainer { * @throws BuildException if one of the nested tasks fails. */ public function main() { - foreach($this->nestedTasks as $task) { - $task->perform(); - } + foreach($this->nestedTasks as $task) { + $task->perform(); + } } } diff --git a/buildscripts/phing/classes/phing/tasks/system/TaskdefTask.php b/buildscripts/phing/classes/phing/tasks/system/TaskdefTask.php index 4a90e106..84552d69 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/TaskdefTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/TaskdefTask.php @@ -1,7 +1,7 @@ <?php /* - * $Id: TaskdefTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: df52def0bb44ce1b0909f5e8858e79b2ef88ca0f $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -21,6 +21,7 @@ */ require_once 'phing/Task.php'; +include_once 'phing/system/io/PhingFile.php'; /** * Register a task for use within a buildfile. @@ -42,7 +43,7 @@ require_once 'phing/Task.php'; * (right now these are just too simple to really justify creating an abstract class) * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.11 $ + * @version $Id: df52def0bb44ce1b0909f5e8858e79b2ef88ca0f $ * @package phing.tasks.system */ class TaskdefTask extends Task { @@ -68,11 +69,17 @@ class TaskdefTask extends Task { * Refid to already defined classpath */ private $classpathId; + + /** + * Name of file to load multiple definitions from. + * @var string + */ + private $typeFile; /** * Set the classpath to be used when searching for component being defined * - * @param Path $classpath An Path object containing the classpath. + * @param Path $classpath A Path object containing the classpath. */ public function setClasspath(Path $classpath) { if ($this->classpath === null) { @@ -84,6 +91,8 @@ class TaskdefTask extends Task { /** * Create the classpath to be used when searching for component being defined + * + * @return Path */ public function createClasspath() { if ($this->classpath === null) { @@ -116,12 +125,41 @@ class TaskdefTask extends Task { $this->classname = $class; } + /** + * Sets the file of definitionas to use to use. + * @param string $file + */ + public function setFile($file) { + $this->typeFile = $file; + } + /** Main entry point */ public function main() { - if ($this->name === null || $this->classname === null) { + if ($this->typeFile === null && + ($this->name === null || $this->classname === null)) { throw new BuildException("You must specify name and class attributes for <taskdef>."); } - $this->log("Task " . $this->name . " will be handled by class " . $this->classname, PROJECT_MSG_VERBOSE); - $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); + if ($this->typeFile == null) { + $this->log("Task " . $this->name . " will be handled by class " . $this->classname, Project::MSG_VERBOSE); + $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); + } else { + try { // try to load taskdefs given in file + $props = new Properties(); + $in = new PhingFile((string) $this->typeFile); + + if ($in === null) { + throw new BuildException("Can't load task list {$this->typeFile}"); + } + $props->load($in); + + $enum = $props->propertyNames(); + foreach($enum as $key) { + $value = $props->getProperty($key); + $this->project->addTaskDefinition($key, $value, $this->classpath); + } + } catch (IOException $ioe) { + throw new BuildException("Can't load task list {$this->typeFile}"); + } + } } } diff --git a/buildscripts/phing/classes/phing/tasks/system/TouchTask.php b/buildscripts/phing/classes/phing/tasks/system/TouchTask.php index 6c6c4080..3c45d0d3 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/TouchTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/TouchTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: TouchTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: e581b40ff4e3eac5f62a32b48b4a22285cbc51c1 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,7 +31,7 @@ include_once 'phing/system/io/IOException.php'; * * If the file to touch doesn't exist, an empty one is created. * - * @version $Revision: 1.12 $ + * @version $Id$ * @package phing.tasks.system */ class TouchTask extends Task { @@ -117,7 +117,7 @@ class TouchTask extends Task { function _touch() { if ($this->file !== null) { if (!$this->file->exists()) { - $this->log("Creating " . $this->file->__toString(), PROJECT_MSG_INFO); + $this->log("Creating " . $this->file->__toString(), Project::MSG_INFO); try { // try to create file $this->file->createNewFile(); } catch(IOException $ioe) { diff --git a/buildscripts/phing/classes/phing/tasks/system/TryCatchTask.php b/buildscripts/phing/classes/phing/tasks/system/TryCatchTask.php new file mode 100644 index 00000000..b27d829b --- /dev/null +++ b/buildscripts/phing/classes/phing/tasks/system/TryCatchTask.php @@ -0,0 +1,123 @@ +<?php +/* + * $Id: acc9e5d431141ae13ea43c1ed1d3177a4fb60bf9 $ + * + * 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>. + */ + +include_once 'phing/Task.php'; + +/** + * A wrapper task that lets you run tasks(s) when another set + * of tasks fails. + * + * Inspired by {@link http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html} + * + * @author Michiel Rook <mrook@php.net> + * @version $Id: acc9e5d431141ae13ea43c1ed1d3177a4fb60bf9 $ + * @package phing.tasks.system + */ +class TryCatchTask extends Task +{ + protected $propertyName = ""; + + protected $tryContainer = null; + protected $catchContainer = null; + protected $finallyContainer = null; + + /** + * Main method + * + * @throws BuildException + * @return void + */ + public function main() + { + $exc = null; + + if (empty($this->tryContainer)) { + throw new BuildException('A nested <try> element is required'); + } + + try { + $this->tryContainer->perform(); + } catch (BuildException $e) { + if (!empty($this->propertyName)) { + $this->project->setProperty($this->propertyName, $e->getMessage()); + } + + if (!empty($this->referenceName)) { + $this->project->addReference($this->referenceName, $e); + } + + if (!empty($this->catchContainer)) { + $this->catchContainer->perform(); + } else { + $exc = $e; + } + } + + if (!empty($this->finallyContainer)) { + $this->finallyContainer->perform(); + } + + if (!empty($exc)) { + throw $exc; + } + } + + /** + * Sets the name of the property that will + * contain the exception message. + * + * @param string $property + */ + public function setProperty($property) + { + $this->propertyName = (string) $property; + } + + /** + * Add nested <try> element + * + * @param SequentialTask $container + */ + public function addTry(SequentialTask $container) + { + $this->tryContainer = $container; + } + + /** + * Add nested <catch> element + * + * @param SequentialTask $container + */ + public function addCatch(SequentialTask $container) + { + $this->catchContainer = $container; + } + + /** + * Add nested <finally> element + * + * @param SequentialTask $container + */ + public function addFinally(SequentialTask $container) + { + $this->finallyContainer = $container; + } +} diff --git a/buildscripts/phing/classes/phing/tasks/system/TstampTask.php b/buildscripts/phing/classes/phing/tasks/system/TstampTask.php index 9341c3dd..44f2c3f0 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/TstampTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/TstampTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: TstampTask.php 58 2006-04-28 14:41:04Z mrook $ + * $Id: c0693134153e6095ab198edb5cf204f53bb7ba69 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,41 +27,41 @@ require_once 'phing/Task.php'; * * Based on Ant's Tstamp task. * - * @author Michiel Rook <michiel@trendserver.nl> - * @version $Revision: 1.6 $ + * @author Michiel Rook <mrook@php.net> + * @version $Id$ * @package phing.tasks.system * @since 2.2.0 */ class TstampTask extends Task { - private $customFormats = array(); - - private $prefix = ""; - - /** - * Set a prefix for the properties. If the prefix does not end with a "." - * one is automatically added. - * @param prefix the prefix to use. - */ - public function setPrefix($prefix) - { - $this->prefix = $prefix; - - if (!empty($this->prefix)) - { - $this->prefix.= "."; - } - } - + private $customFormats = array(); + + private $prefix = ""; + + /** + * Set a prefix for the properties. If the prefix does not end with a "." + * one is automatically added. + * @param prefix the prefix to use. + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + + if (!empty($this->prefix)) + { + $this->prefix.= "."; + } + } + /** * Adds a custom format * - * @param TstampCustomFormat custom format + * @param TstampCustomFormat custom format */ - public function addFormat(TstampCustomFormat $cf) - { - $this->customFormats[] = $cf; - } + public function addFormat(TstampCustomFormat $cf) + { + $this->customFormats[] = $cf; + } /** * Create the timestamps. Custom ones are done before @@ -71,21 +71,21 @@ class TstampTask extends Task */ public function main() { - foreach ($this->customFormats as $cf) - { - $cf->execute($this); - } - - $dstamp = strftime('%Y%m%d'); - $this->prefixProperty('DSTAMP', $dstamp); - - $tstamp = strftime('%H%M'); - $this->prefixProperty('TSTAMP', $tstamp); - - $today = strftime('%B %d %Y'); - $this->prefixProperty('TODAY', $today); - } - + foreach ($this->customFormats as $cf) + { + $cf->execute($this); + } + + $dstamp = strftime('%Y%m%d'); + $this->prefixProperty('DSTAMP', $dstamp); + + $tstamp = strftime('%H%M'); + $this->prefixProperty('TSTAMP', $tstamp); + + $today = strftime('%B %d %Y'); + $this->prefixProperty('TODAY', $today); + } + /** * helper that encapsulates prefix logic and property setting * policy (i.e. we use setNewProperty instead of setProperty). @@ -96,73 +96,76 @@ class TstampTask extends Task } } +/** + * @package phing.tasks.system + */ class TstampCustomFormat { - private $propertyName = ""; - private $pattern = ""; - private $locale = ""; - - /** - * The property to receive the date/time string in the given pattern - * - * @param propertyName the name of the property. - */ - public function setProperty($propertyName) - { - $this->propertyName = $propertyName; - } + private $propertyName = ""; + private $pattern = ""; + private $locale = ""; + + /** + * The property to receive the date/time string in the given pattern + * + * @param propertyName the name of the property. + */ + public function setProperty($propertyName) + { + $this->propertyName = $propertyName; + } - /** - * The date/time pattern to be used. The values are as - * defined by the PHP strftime() function. - * - * @param pattern - */ - public function setPattern($pattern) - { - $this->pattern = $pattern; - } - - /** - * The locale used to create date/time string. - * - * @param locale - */ - public function setLocale($locale) - { - $this->locale = $locale; - } - - /** - * validate parameter and execute the format. - * - * @param TstampTask reference to task - */ - public function execute(TstampTask $tstamp) - { - if (empty($this->propertyName)) - { - throw new BuildException("property attribute must be provided"); - } + /** + * The date/time pattern to be used. The values are as + * defined by the PHP strftime() function. + * + * @param pattern + */ + public function setPattern($pattern) + { + $this->pattern = $pattern; + } + + /** + * The locale used to create date/time string. + * + * @param locale + */ + public function setLocale($locale) + { + $this->locale = $locale; + } + + /** + * validate parameter and execute the format. + * + * @param TstampTask reference to task + */ + public function execute(TstampTask $tstamp) + { + if (empty($this->propertyName)) + { + throw new BuildException("property attribute must be provided"); + } - if (empty($this->pattern)) - { - throw new BuildException("pattern attribute must be provided"); - } - - if (!empty($this->locale)) - { - setlocale(LC_ALL, $this->locale); - } - - $value = strftime($this->pattern); - $tstamp->prefixProperty($this->propertyName, $value); - - if (!empty($this->locale)) - { - // reset locale - setlocale(LC_ALL, NULL); - } - } + if (empty($this->pattern)) + { + throw new BuildException("pattern attribute must be provided"); + } + + if (!empty($this->locale)) + { + setlocale(LC_ALL, $this->locale); + } + + $value = strftime($this->pattern); + $tstamp->prefixProperty($this->propertyName, $value); + + if (!empty($this->locale)) + { + // reset locale + setlocale(LC_ALL, NULL); + } + } } -?> + diff --git a/buildscripts/phing/classes/phing/tasks/system/TypedefTask.php b/buildscripts/phing/classes/phing/tasks/system/TypedefTask.php index de058c90..c03e716d 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/TypedefTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/TypedefTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: TypedefTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 6122dcb36b79ffe3c3fb430a0b4586d9d145410b $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -43,7 +43,7 @@ require_once 'phing/Task.php'; * (right now these are just too simple to really justify creating an abstract class) * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.7 $ + * @version $Id$ * @package phing.tasks.system */ class TypedefTask extends Task { @@ -71,7 +71,7 @@ class TypedefTask extends Task { /** * Set the classpath to be used when searching for component being defined * - * @param Path $classpath An Path object containing the classpath. + * @param Path $classpath A Path object containing the classpath. */ public function setClasspath(Path $classpath) { if ($this->classpath === null) { @@ -83,6 +83,8 @@ class TypedefTask extends Task { /** * Create the classpath to be used when searching for component being defined + * + * @return Path */ public function createClasspath() { if ($this->classpath === null) { diff --git a/buildscripts/phing/classes/phing/tasks/system/UpToDateTask.php b/buildscripts/phing/classes/phing/tasks/system/UpToDateTask.php index 720fae12..1954fe88 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/UpToDateTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/UpToDateTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: UpToDateTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 5b0af63dfa9acb85374dcdd2d7fd866ce81391d0 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -21,6 +21,7 @@ require_once 'phing/Task.php'; include_once 'phing/tasks/system/condition/Condition.php'; +include_once 'phing/tasks/system/PropertyTask.php'; include_once 'phing/util/DirectoryScanner.php'; include_once 'phing/util/SourceFileScanner.php'; include_once 'phing/mappers/MergeMapper.php'; @@ -33,7 +34,7 @@ include_once 'phing/mappers/MergeMapper.php'; * @author William Ferguson <williamf@mincom.com> (Ant) * @author Hiroaki Nakamura <hnakamur@mc.neweb.ne.jp> (Ant) * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant) - * @version $Revision: 1.6 $ + * @version $Id$ * @package phing.tasks.system */ class UpToDateTask extends Task implements Condition { @@ -43,6 +44,7 @@ class UpToDateTask extends Task implements Condition { private $_sourceFile; private $_targetFile; private $sourceFileSets = array(); + private $_filelists = array(); protected $mapperElement = null; @@ -57,6 +59,14 @@ class UpToDateTask extends Task implements Condition { } /** + * Get property name + * @param property the name of the property to set if Target is up-to-date. + */ + public function getProperty() { + return $this->_property; + } + + /** * The value to set the named property to if the target file is more * up-to-date than (each of) the source file(s). Defaults to 'true'. * @@ -101,6 +111,8 @@ class UpToDateTask extends Task implements Condition { /** * Nested <srcfiles> element. + * + * @deprecated Deprecated since Phing 2.4.0 */ public function createSrcfiles() { $fs = new FileSet(); @@ -109,6 +121,22 @@ class UpToDateTask extends Task implements Condition { } /** + * Nested <fileset> element. + */ + public function addFileset(FileSet $fs) { + $this->sourceFileSets[] = $fs; + } + + /** + * Supports embedded <filelist> element. + * @return FileList + */ + public function createFileList() { + $num = array_push($this->_filelists, new FileList()); + return $this->_filelists[$num-1]; + } + + /** * Defines the FileNameMapper to use (nested mapper element). */ public function createMapper() { @@ -126,15 +154,15 @@ class UpToDateTask extends Task implements Condition { * @return boolean */ public function evaluate() { - if (count($this->sourceFileSets) === 0 && $this->_sourceFile === null) { + if (count($this->sourceFileSets) == 0 && count($this->_filelists) == 0 && $this->_sourceFile === null) { throw new BuildException("At least one srcfile or a nested " - . "<srcfiles> element must be set."); + . "<fileset> or <filelist> element must be set."); } - if (count($this->sourceFileSets) > 0 && $this->_sourceFile !== null) { + if ((count($this->sourceFileSets) > 0 || count($this->_filelists) > 0) && $this->_sourceFile !== null) { throw new BuildException("Cannot specify both the srcfile " - . "attribute and a nested <srcfiles> " - . "element."); + . "attribute and a nested <fileset> " + . "or <filelist> element."); } if ($this->_targetFile === null && $this->mapperElement === null) { @@ -161,6 +189,13 @@ class UpToDateTask extends Task implements Condition { $ds->getIncludedFiles()); } + for($i=0,$size=count($this->_filelists); $i < $size && $upToDate; $i++) { + $fl = $this->_filelists[$i]; + $srcFiles = $fl->getFiles($this->project); + $upToDate = $upToDate && $this->scanDir($fs->getDir($this->project), + $srcFiles); + } + if ($this->_sourceFile !== null) { if ($this->mapperElement === null) { $upToDate = $upToDate && @@ -189,13 +224,18 @@ class UpToDateTask extends Task implements Condition { } $upToDate = $this->evaluate(); if ($upToDate) { - $this->project->setNewProperty($this->_property, $this->getValue()); + $property = $this->project->createTask('property'); + $property->setName($this->getProperty()); + $property->setValue($this->getValue()); + $property->setOverride(true); + $property->main(); // execute + if ($this->mapperElement === null) { $this->log("File \"" . $this->_targetFile->getAbsolutePath() - . "\" is up-to-date.", PROJECT_MSG_VERBOSE); + . "\" is up-to-date.", Project::MSG_VERBOSE); } else { $this->log("All target files are up-to-date.", - PROJECT_MSG_VERBOSE); + Project::MSG_VERBOSE); } } } diff --git a/buildscripts/phing/classes/phing/tasks/system/WaitForTask.php b/buildscripts/phing/classes/phing/tasks/system/WaitForTask.php new file mode 100755 index 00000000..00bcff1e --- /dev/null +++ b/buildscripts/phing/classes/phing/tasks/system/WaitForTask.php @@ -0,0 +1,188 @@ +<?php +/* + * $Id: dae67bf2b9c154d4614f30e9ba85c16782550bb3 $ + * + * 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/Task.php'; + +/** + * Based on Apache Ant Wait For: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @author Michiel Rook <mrook@php.net> + * @version $Id$ + * @package phing.tasks.system + */ +class WaitForTask extends ConditionBase +{ + const ONE_MILLISECOND = 1; + const ONE_SECOND = 1000; + const ONE_MINUTE = 60000; + const ONE_HOUR = 3600000; + const ONE_DAY = 86400000; + const ONE_WEEK = 604800000; + + const DEFAULT_MAX_WAIT_MILLIS = 180000; + const DEFAULT_CHECK_MILLIS = 500; + + protected $maxWait = self::DEFAULT_MAX_WAIT_MILLIS; + protected $maxWaitMultiplier = self::ONE_MILLISECOND; + + protected $checkEvery = self::DEFAULT_CHECK_MILLIS; + protected $checkEveryMultiplier = self::ONE_MILLISECOND; + + protected $timeoutProperty = null; + + /** + * Set the maximum length of time to wait. + * @param int $maxWait + */ + public function setMaxWait($maxWait) + { + $this->maxWait = (int) $maxWait; + } + + /** + * Set the max wait time unit + * @param string $maxWaitUnit + */ + public function setMaxWaitUnit($maxWaitUnit) + { + $this->maxWaitMultiplier = $this->_convertUnit($maxWaitUnit); + } + + /** + * Set the time between each check + * @param int $checkEvery + */ + public function setCheckEvery($checkEvery) + { + $this->checkEvery = (int) $checkEvery; + } + + /** + * Set the check every time unit + * @param string $checkEveryUnit + */ + public function setCheckEveryUnit($checkEveryUnit) + { + $this->checkEveryMultiplier = $this->_convertUnit($checkEveryUnit); + } + + /** + * Name of the property to set after a timeout. + * @param string $timeoutProperty + */ + public function setTimeoutProperty($timeoutProperty) + { + $this->timeoutProperty = $timeoutProperty; + } + + /** + * Convert the unit to a multipler. + * @param string $unit + */ + protected function _convertUnit($unit) + { + switch ($unit) { + case "week": { + return self::ONE_WEEK; + } + + case "day": { + return self::ONE_DAY; + } + + case "hour": { + return self::ONE_HOUR; + } + + case "minute": { + return self::ONE_MINUTE; + } + + case "second": { + return self::ONE_SECOND; + } + + case "millisecond": { + return self::ONE_MILLISECOND; + } + + default: { + throw new BuildException("Illegal unit '$unit'"); + } + } + } + + /** + * Check repeatedly for the specified conditions until they become + * true or the timeout expires. + * @throws BuildException + */ + public function main() + { + if ($this->countConditions() > 1) { + throw new BuildException("You must not nest more than one condition into <waitfor>"); + } + + if ($this->countConditions() < 1) { + throw new BuildException("You must nest a condition into <waitfor>"); + } + + $cs = $this->getIterator(); + $condition = $cs->current(); + + $maxWaitMillis = $this->maxWait * $this->maxWaitMultiplier; + $checkEveryMillis = $this->checkEvery * $this->checkEveryMultiplier; + + $start = microtime(true) * 1000; + $end = $start + $maxWaitMillis; + + while (microtime(true) * 1000 < $end) { + if ($condition->evaluate()) { + $this->log("waitfor: condition was met", Project::MSG_VERBOSE); + + return; + } + + usleep($checkEveryMillis * 1000); + } + + $this->log("waitfor: timeout", Project::MSG_VERBOSE); + + if ($this->timeoutProperty != null) { + $this->project->setNewProperty($this->timeoutProperty, "true"); + } + } +}
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/system/WarnTask.php b/buildscripts/phing/classes/phing/tasks/system/WarnTask.php index 50318e71..28f0ad92 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/WarnTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/WarnTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: WarnTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: a2192433abbea9c5fe4b4ddb518cde8c09a643da $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -22,14 +22,14 @@ require_once 'phing/tasks/system/EchoTask.php'; /** - * Simple task to echo a warning message (PROJECT_MSG_WARN) to all output devices. + * Simple task to echo a warning message (Project::MSG_WARN) to all output devices. * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.1 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @version $Id$ * @package phing.tasks.system */ class WarnTask extends EchoTask { function main() { - $this->log($this->msg, PROJECT_MSG_WARN); + $this->log($this->msg, Project::MSG_WARN); } } diff --git a/buildscripts/phing/classes/phing/tasks/system/XsltTask.php b/buildscripts/phing/classes/phing/tasks/system/XsltTask.php index 0374aa59..7155caf8 100644 --- a/buildscripts/phing/classes/phing/tasks/system/XsltTask.php +++ b/buildscripts/phing/classes/phing/tasks/system/XsltTask.php @@ -1,6 +1,6 @@ <?php /* - * $Id: XsltTask.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 8f87e1c7908c06223382baf628d018c3a0f10824 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -31,7 +31,7 @@ include_once 'phing/filters/XsltFilter.php'; * in the <filterchains> section. * * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.8 $ + * @version $Id: 8f87e1c7908c06223382baf628d018c3a0f10824 $ * @package phing.tasks.system */ class XsltTask extends CopyTask { @@ -57,7 +57,7 @@ class XsltTask extends CopyTask { * @see CopyTask::main() */ function main() { - $this->log("Doing XSLT transformation using stylesheet " . $this->xsltFilter->getStyle(), PROJECT_MSG_VERBOSE); + $this->log("Doing XSLT transformation using stylesheet " . $this->xsltFilter->getStyle(), Project::MSG_VERBOSE); $this->xsltFilter->setParams($this->parameters); parent::main(); } @@ -71,6 +71,28 @@ class XsltTask extends CopyTask { } /** + * Whether to resolve entities in the XML document. + * + * @param bool $resolveExternals + * + * @since 2.4 + */ + function setResolveDocumentExternals($resolveExternals) { + $this->xsltFilter->setResolveDocumentExternals((bool)$resolveExternals); + } + + /** + * Whether to resolve entities in the stylesheet. + * + * @param bool $resolveExternals + * + * @since 2.4 + */ + function setResolveStylesheetExternals($resolveExternals) { + $this->xsltFilter->setResolveStylesheetExternals((bool)$resolveExternals); + } + + /** * Support nested <param> tags useing XSLTParam class. * @return XSLTParam */ diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/AndCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/AndCondition.php index c16ce499..41b57a8e 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/AndCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/AndCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: AndCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 69074307e3d1aae5fbfaa03842f5a8fc14b49625 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,8 +29,8 @@ require_once 'phing/tasks/system/condition/ConditionBase.php'; * * @author Hans Lellelid <hans@xmpl.org> * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.7 $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @package phing.tasks.system.condition */ class AndCondition extends ConditionBase implements Condition { diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/Condition.php b/buildscripts/phing/classes/phing/tasks/system/condition/Condition.php index 73e0c232..9c9d90e5 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/Condition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/Condition.php @@ -1,7 +1,7 @@ <?php /* - * $Id: Condition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: c971532805c4ac4c3d3cbf05a5c53abe7279b336 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -26,7 +26,7 @@ * Each condition must implement a method applying to this prototye: * * @author Hans Lellelid <hans@xmpl.org> - * @version $Revision: 1.4 $ + * @version $Id$ * @package phing.tasks.system.condition */ interface Condition { @@ -36,4 +36,3 @@ interface Condition { */ public function evaluate(); } -?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/ConditionBase.php b/buildscripts/phing/classes/phing/tasks/system/condition/ConditionBase.php index 1c09fe49..e21ce4e4 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/ConditionBase.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/ConditionBase.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ConditionBase.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 8721880badf6aee475a8cb87c88ca3dc4299efb8 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,10 +29,10 @@ include_once 'phing/tasks/system/condition/Condition.php'; * conditions - ensures that the types of conditions inside the task * and the "container" conditions are in sync. * - * @author Hans Lellelid <hans@xmpl.org> + * @author Hans Lellelid <hans@xmpl.org> * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.16 $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @package phing.tasks.system.condition */ abstract class ConditionBase extends ProjectComponent implements IteratorAggregate { @@ -156,6 +156,8 @@ abstract class ConditionBase extends ProjectComponent implements IteratorAggrega /** * "Inner" class for handling enumerations. * Uses build-in PHP5 iterator support. + * + * @package phing.tasks.system.condition */ class ConditionEnumeration implements Iterator { diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/ContainsCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/ContainsCondition.php index 95849cd8..d7fb80ac 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/ContainsCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/ContainsCondition.php @@ -1,7 +1,7 @@ <?php /* - * $Id: ContainsCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 6cdecc53a715fce4601b1ceb64c8ec95d29c1468 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,7 +27,7 @@ require_once 'phing/tasks/system/condition/Condition.php'; * * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant) - * @version $Revision: 1.3 $ + * @version $Id: 6cdecc53a715fce4601b1ceb64c8ec95d29c1468 $ * @package phing.tasks.system.condition */ class ContainsCondition implements Condition { @@ -71,6 +71,6 @@ class ContainsCondition implements Condition { return $this->caseSensitive ? strpos($this->string, $this->subString) !== false - : substr(strtolower($this->string), strtolower($this->subString)) !== false; + : strpos(strtolower($this->string), strtolower($this->subString)) !== false; } } diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/EqualsCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/EqualsCondition.php index 32d51380..4be4e8fe 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/EqualsCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/EqualsCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: EqualsCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: faec716501a00cdeb84b8c893b5bbe5c76064dec $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -26,8 +26,8 @@ require_once 'phing/tasks/system/condition/Condition.php'; * binary safe manner. Implements the condition interface specification. * * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.7 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id: faec716501a00cdeb84b8c893b5bbe5c76064dec $ * @access public * @package phing.tasks.system.condition */ diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/IsFalseCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/IsFalseCondition.php index ebbd1a3d..8a1b3dcf 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/IsFalseCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/IsFalseCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: IsFalseCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: f7d355bdf8f7aa539afb572e2fe033ffd3bcd89b $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,7 +27,7 @@ require_once 'phing/tasks/system/condition/Condition.php'; * * @author Hans Lellelid (Phing) * @author Steve Loughran (Ant) - * @version $Revision: 1.4 $ + * @version $Id: f7d355bdf8f7aa539afb572e2fe033ffd3bcd89b $ * @package phing.tasks.system.condition */ class IsFalseCondition extends ProjectComponent implements Condition { diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/IsSetCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/IsSetCondition.php index 4f81c50f..24f3f609 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/IsSetCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/IsSetCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: IsSetCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: 5c5924da5cff2626af09b4908703a21eec79c777 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -27,7 +27,7 @@ require_once 'phing/tasks/system/condition/Condition.php'; * * @author Hans Lellelid <hans@xmpl.org> (Phing) * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant) - * @version $Revision: 1.4 $ + * @version $Id$ * @package phing.tasks.system.condition */ class IsSetCondition extends ProjectComponent implements Condition { diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/IsTrueCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/IsTrueCondition.php index 4affefc5..8c6d19fc 100644 --- a/buildscripts/phing/classes/phing/tasks/system/condition/IsTrueCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/IsTrueCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: IsTrueCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: d567f7c477e075a5c06d3f8e07ff8a7412cf31cd $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/NotCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/NotCondition.php index c76ef2b8..081876af 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/NotCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/NotCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: NotCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: d8c985da7c759357135cf717b1f4b52a1bd50cb6 $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -28,8 +28,8 @@ require_once 'phing/tasks/system/condition/ConditionBase.php'; * and vice versa. * * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.6 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @access public * @package phing.tasks.system.condition */ diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/OrCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/OrCondition.php index 778abfd0..d88df271 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/OrCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/OrCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: OrCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: adcd6785a85304a0860cc3dd9a0146d965c1cb0c $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,7 +29,7 @@ require_once 'phing/tasks/system/condition/ConditionBase.php'; * * @author Andreas Aderhold <andi@binarycloud.com> * @copyright 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.8 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @version $Id$ * @access public * @package phing.tasks.system.condition */ diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/OsCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/OsCondition.php index d80729e7..50a7174f 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/OsCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/OsCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: OsCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: d63246e2d25230f5ba6e45a651497e3ba01abe2c $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -25,8 +25,8 @@ require_once 'phing/tasks/system/condition/ConditionBase.php'; * Condition that tests the OS type. * * @author Andreas Aderhold <andi@binarycloud.com> - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.8 $ $Date: 2006-04-28 10:49:47 -0400 (Fri, 28 Apr 2006) $ + * @copyright 2001,2002 THYRELL. All rights reserved + * @version $Id$ * @access public * @package phing.tasks.system.condition */ @@ -40,20 +40,20 @@ class OsCondition implements Condition { function evaluate() { $osName = strtolower(Phing::getProperty("os.name")); - + if ($this->family !== null) { if ($this->family === "windows") { return StringHelper::startsWith("win", $osName); } elseif ($this->family === "mac") { return (strpos($osName, "mac") !== false || strpos($osName, "darwin") !== false); } elseif ($this->family === ("unix")) { - return ( - StringHelper::endsWith("ix", $osName) || - StringHelper::endsWith("ux", $osName) || - StringHelper::endsWith("bsd", $osName) || - StringHelper::startsWith("sunos", $osName) || - StringHelper::startsWith("darwin", $osName) - ); + return ( + StringHelper::endsWith("ix", $osName) || + StringHelper::endsWith("ux", $osName) || + StringHelper::endsWith("bsd", $osName) || + StringHelper::startsWith("sunos", $osName) || + StringHelper::startsWith("darwin", $osName) + ); } throw new BuildException("Don't know how to detect os family '" . $this->family . "'"); } diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php index 09324fb8..08e291e3 100644..100755 --- a/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php @@ -1,6 +1,6 @@ <?php /* - * $Id: ReferenceExistsCondition.php 59 2006-04-28 14:49:47Z mrook $ + * $Id: e62ed1e00cc6ed859746760c89bc0f873db4620a $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -25,7 +25,7 @@ require_once 'phing/ProjectComponent.php'; require_once 'phing/tasks/system/cond * Condition that tests whether a given reference exists. * * @author Matthias Pigulla <mp@webfactory.de> (Phing) - * @version $Revision: 1.1 $ + * @version $Id$ * @package phing.tasks.system.condition */ class ReferenceExistsCondition extends ProjectComponent implements Condition { |