/** * Executes this task. */ public function main() { if ($this->file === null) { throw new BuildException('The file attribute must be specified'); } $return = getcwd(); try { /* Resolve paths correctly: Everything we do as far as * configuration is concerned should be relative to the * new project file. */ chdir($this->file->getAbsoluteFile()->getParent()); $project = new AgaviProxyProject($this->project); $project->addReference('phing.parsing.context', new AgaviProxyXmlContext($project)); $project->setUserProperty('phing.file', $this->file->getAbsolutePath()); $project->init(); Phing::setCurrentProject($project); ProjectConfigurator::configureProject($project, $this->file); foreach ($project->getTargets() as $name => $target) { /* Make sure we don't add proxy targets back to our own project. */ if ($target instanceof AgaviProxyTarget && $target->getTarget()->getProject() === $this->project) { continue; } if (array_key_exists($name, $this->project->getTargets())) { throw new BuildException(sprintf('Target conflict: %s already exists in project (attempted to add from %s)', $name, $this->file->getAbsolutePath())); } $proxy = new AgaviProxyTarget(); $proxy->setName($name); $proxy->setDescription($target->getDescription()); $proxy->setTarget($target); $this->project->addTarget($name, $proxy); } Phing::setCurrentProject($this->project); $this->log(sprintf('Importing external build file %s', $this->file->getAbsolutePath()), Project::MSG_INFO); } catch (Exception $e) { $this->log(sprintf('Could not read %s: %s (skipping)', $this->file->getAbsolutePath(), $e->getMessage()), Project::MSG_WARN); } /* Go back from whence we came. */ chdir($return); }
/** * Executes this target. */ public function main() { if ($this->name === null) { throw new BuildException('The name attribute must be specified'); } /* Words cannot describe how ridiculously f*****g stupid this is. Phing * seems to resolve properties only once, ever, so in order to run a * target multiple times with different properties we'll have to create * a new project, parse the build file all over again, copy everything * over from the current project, execute the new target, and then copy * everything back. F**k. */ $project = new Project(); try { foreach ($this->project->getBuildListeners() as $listener) { $project->addBuildListener($listener); } $project->setInputHandler($this->project->getInputHandler()); $this->project->copyUserProperties($project); $this->project->copyInheritedProperties($project); foreach ($this->project->getProperties() as $name => $property) { if ($project->getProperty($name) === null) { $project->setNewProperty($name, $property); } } $project->init(); ProjectConfigurator::configureProject($project, new PhingFile($this->project->getProperty('phing.file'))); Phing::setCurrentProject($project); $project->executeTarget($this->name); } catch (BuildException $be) { if ($this->exceptionsFatal) { throw $be; } else { $this->log('Ignoring build exception: ' . $be->getMessage(), Project::MSG_WARN); $this->log('Continuing build', Project::MSG_INFO); } } Phing::setCurrentProject($this->project); $project->copyUserProperties($this->project); $project->copyInheritedProperties($this->project); foreach ($project->getProperties() as $name => $property) { if ($this->project->getProperty($name) === null) { $this->project->setNewProperty($name, $property); } } /* F**k. */ unset($project); }
/** * Executes this target. * * @author Noah Fontes <*****@*****.**> * @since 1.0.0 */ public function main() { $thisProject = $this->getProject(); $project = $this->target->getProject(); Phing::setCurrentProject($project); chdir($project->getBasedir()->getAbsolutePath()); /* Assign properties for consistency. */ $thisProject->copyUserProperties($project); $thisProject->copyInheritedProperties($project); foreach ($thisProject->getProperties() as $name => $property) { if (!AgaviProxyProject::isPropertyProtected($name) && $project->getProperty($name) === null) { $project->setNewProperty($name, $property); } } /* Execute the proxied target. */ $project->executeTarget($this->target->getName()); Phing::setCurrentProject($thisProject); chdir($thisProject->getBasedir()->getAbsolutePath()); $project->copyUserProperties($thisProject); $project->copyInheritedProperties($thisProject); foreach ($project->getProperties() as $name => $property) { if (!AgaviProxyProject::isPropertyProtected($name) && $thisProject->getProperty($name) === null) { $thisProject->setNewProperty($name, $property); } } }
$logger = new AgaviProxyBuildLogger(new $GLOBALS['LOGGER']()); $logger->setMessageOutputLevel($GLOBALS['VERBOSE'] ? Project::MSG_VERBOSE : Project::MSG_INFO); $logger->setOutputStream($GLOBALS['OUTPUT']); $logger->setErrorStream($GLOBALS['ERROR']); $project->addBuildListener($logger); $project->setInputHandler(new DefaultInputHandler()); $project->setUserProperty('phing.file', $GLOBALS['BUILD']->getAbsolutePath()); $project->setUserProperty('phing.version', Phing::getPhingVersion()); /* Phing f***s with the cwd. Really, brilliant. */ $project->setUserProperty('application.startdir', START_DIRECTORY); foreach ($GLOBALS['PROPERTIES'] as $name => $value) { $project->setUserProperty($name, $value); } $project->init(); ProjectConfigurator::configureProject($project, $GLOBALS['BUILD']); Phing::setCurrentProject($project); if ($GLOBALS['SHOW_LIST'] === true) { input_help_display(); $GLOBALS['OUTPUT']->write(PHP_EOL); $GLOBALS['OUTPUT']->write('Targets:' . PHP_EOL); $size = 0; $targets = array(); foreach ($project->getTargets() as $target) { $name = $target->getName(); $nameSize = strlen($name); $description = $target->getDescription(); if ($description !== null) { $size = $nameSize > $size ? $nameSize : $size; $targets[$name] = $description; } }