/** * Scans the parameters list for the "lines" parameter and uses * it to set the number of lines to be returned in the filtered stream. * also scan for skip parameter. * * @throws BuildException */ private function initialize() { // get parameters $params = $this->getParameters(); if ($params !== null) { /** @var Parameter $param */ foreach ($params as $param) { if ('prepend' === $param->getName()) { $this->setPrepend(new PhingFile($param->getValue())); continue; } if ('append' === $param->getName()) { $this->setAppend(new PhingFile($param->getValue())); continue; } } } if ($this->prepend !== null) { if (!$this->prepend->isAbsolute()) { $this->prepend = new PhingFile($this->getProject()->getBasedir(), $this->prepend->getPath()); } $this->prependReader = new BufferedReader(new FileReader($this->prepend)); } if ($this->append !== null) { if (!$this->append->isAbsolute()) { $this->append = new PhingFile($this->getProject()->getBasedir(), $this->append->getPath()); } $this->appendReader = new BufferedReader(new FileReader($this->append)); } }
/** * Executes initialization actions required to setup the project. Usually * this method handles the attributes of a tag. * * @param string the tag that comes in * @param array attributes the tag carries * @param object the ProjectConfigurator object * @throws ExpatParseException if attributes are incomplete or invalid * @access public */ function init($tag, $attrs) { $def = null; $name = null; $id = null; $desc = null; $baseDir = null; // some shorthands $project = $this->configurator->project; $buildFileParent = $this->configurator->buildFileParent; foreach ($attrs as $key => $value) { if ($key === "default") { $def = $value; } elseif ($key === "name") { $name = $value; } elseif ($key === "id") { $id = $value; } elseif ($key === "basedir") { $baseDir = $value; } elseif ($key === "description") { $desc = $value; } else { throw new ExpatParseException("Unexpected attribute '{$key}'"); } } if ($def === null) { throw new ExpatParseException("The default attribute of project is required"); } $project->setDefaultTarget($def); if ($name !== null) { $project->setName($name); $project->addReference($name, $project); } if ($id !== null) { $project->addReference($id, $project); } if ($desc !== null) { $project->setDescription($desc); } if ($project->getProperty("project.basedir") !== null) { $project->setBasedir($project->getProperty("project.basedir")); } else { if ($baseDir === null) { $project->setBasedir($buildFileParent->getAbsolutePath()); } else { // check whether the user has specified an absolute path $f = new PhingFile($baseDir); if ($f->isAbsolute()) { $project->setBasedir($baseDir); } else { $project->setBaseDir($project->resolveFile($baseDir, $buildFileParent)); } } } }
/** * @param PhingFile $file * @return bool * @throws IOException */ private function _checkFile1(PhingFile $file) { // Resolve symbolic links if ($this->followSymlinks && $file->isLink()) { $linkTarget = new PhingFile($file->getLinkTarget()); if ($linkTarget->isAbsolute()) { $file = $linkTarget; } else { $fs = FileSystem::getFileSystem(); $file = new PhingFile($fs->resolve($fs->normalize($file->getParent()), $fs->normalize($file->getLinkTarget()))); } } if ($this->type !== null) { if ($this->type === "dir") { return $file->isDirectory(); } else { if ($this->type === "file") { return $file->isFile(); } } } return $file->exists(); }
private function _getFullPath($filename) { $file = new PhingFile($filename); if (!$file->isAbsolute()) { $file = new PhingFile($this->project->getBasedir(), $filename); } $result = $file->getPath(); return $result; }
/** * Executes initialization actions required to setup the project. Usually * this method handles the attributes of a tag. * * @param string the tag that comes in * @param array attributes the tag carries * @param object the ProjectConfigurator object * @throws ExpatParseException if attributes are incomplete or invalid * @access public */ function init($tag, $attrs) { $def = null; $name = null; $id = null; $desc = null; $baseDir = null; $ver = null; // some shorthands $project = $this->configurator->project; $buildFileParent = $this->configurator->buildFileParent; foreach ($attrs as $key => $value) { if ($key === "default") { $def = $value; } elseif ($key === "name") { $name = $value; } elseif ($key === "id") { $id = $value; } elseif ($key === "basedir") { $baseDir = $value; } elseif ($key === "description") { $desc = $value; } elseif ($key === "phingVersion") { $ver = $value; } else { throw new ExpatParseException("Unexpected attribute '{$key}'"); } } // these things get done no matter what if (null != $name) { $canonicalName = self::canonicalName($name); $this->configurator->setCurrentProjectName($canonicalName); $path = (string) $this->configurator->getBuildFile(); $project->setUserProperty("phing.file.{$canonicalName}", $path); $project->setUserProperty("phing.dir.{$canonicalName}", dirname($path)); } if (!$this->configurator->isIgnoringProjectTag()) { if ($def === null) { throw new ExpatParseException("The default attribute of project is required"); } $project->setDefaultTarget($def); if ($name !== null) { $project->setName($name); $project->addReference($name, $project); } if ($id !== null) { $project->addReference($id, $project); } if ($desc !== null) { $project->setDescription($desc); } if ($ver !== null) { $project->setPhingVersion($ver); } if ($project->getProperty("project.basedir") !== null) { $project->setBasedir($project->getProperty("project.basedir")); } else { if ($baseDir === null) { $project->setBasedir($buildFileParent->getAbsolutePath()); } else { // check whether the user has specified an absolute path $f = new PhingFile($baseDir); if ($f->isAbsolute()) { $project->setBasedir($baseDir); } else { $project->setBaseDir($project->resolveFile($baseDir, new PhingFile(getcwd()))); } } } } }
/** * Parse a Phing build file and copy the properties, tasks, data types and * targets it defines into the current project. * * @throws BuildException * @return void */ public function main() { if ($this->getOwningTarget() == null || $this->getOwningTarget()->getName() != '') { throw new BuildException("import only allowed as a top-level task"); } // Single file. if ($this->file !== null) { $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); } } $this->importFile($file); } // Filesets. $total_files = 0; $total_dirs = 0; 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->importFile(new PhingFile($fromDir, $srcFiles[$j])); } $dircount = count($srcDirs); $total_dirs = $total_dirs + $dircount; for ($j = 0; $j < $dircount; $j++) { $this->importFile(new PhingFile($fromDir, $srcDirs[$j])); } } }
/** * 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); } }
/** * Parse a Phing build file and copy the properties, tasks, data types and * targets it defines into the current project. * * @throws BuildException * @return void */ public function main() { if (!isset($this->file)) { throw new BuildException("Missing attribute 'file'"); } if ($this->getOwningTarget() == null || $this->getOwningTarget()->getName() != '') { throw new BuildException("import only allowed as a top-level task"); } $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(); // 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 file from {$file->getAbsolutePath()}", Project::MSG_VERBOSE); ProjectConfigurator::configureProject($this->project, $file); }