/** * Set the project associated with this recorder entry. * * @param Project $project the project instance */ public function setProject(Project $project) { $this->project = $project; if ($this->project != null) { $this->project->addBuildListener($this); } }
/** * 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); /** * :NOTE: copy all user properties so that child task may overwrite * properties that were already set in the parent project * * using the Project::copyUserProperties() will result in * properties not adjusted to the new value. */ foreach ($project->getUserProperties() as $name => $property) { $this->project->setUserProperty($name, $property); } $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); }
/** * Bind any registered build listeners to this project. * * This means adding the logger and any build listeners that were specified * with -listener arg. * * @param Project $project * @return void */ private function addBuildListeners(Project $project) { // Add the default listener $project->addBuildListener($this->createLogger()); foreach ($this->listeners as $listenerClassname) { try { $clz = Phing::import($listenerClassname); } catch (Exception $x) { $msg = "Unable to instantiate specified listener " . "class " . $listenerClassname . " : " . $e->getMessage(); throw new ConfigurationException($msg); } $listener = new $clz(); if ($listener instanceof StreamRequiredBuildLogger) { throw new ConfigurationException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)"); } $project->addBuildListener($listener); } }
/** * Bind any default build listeners to this project. * Currently this means adding the logger. * @param Project $project * @return void */ private function addBuildListeners(Project $project) { // Add the default listener $project->addBuildListener($this->createLogger()); }
/** * Bind any registered build listeners to this project. * * This means adding the logger and any build listeners that were specified * with -listener arg. * * @param Project $project * @return void */ private function addBuildListeners(Project $project) { // Add the default listener $project->addBuildListener($this->createLogger()); foreach ($this->listeners as $listenerClassname) { try { $clz = Phing::import($listenerClassname); $listener = new $clz(); $project->addBuildListener($listener); } catch (Exception $e) { $msg = "Unable to instantiate specified listener " . "class " . $listenerClassname . " : " . $e->getMessage(); throw new BuildException($msg); } } }
$GLOBALS['PROPERTIES']['project.directory'] = $GLOBALS['PROJECT_DIRECTORY']; /* Execute Phing. */ try { $project = new Project(); // hax for Mac OS X 10.5 Leopard, where "dim" ANSI colors are broken... if (PHP_OS == 'Darwin' && (isset($_SERVER['TERM_PROGRAM']) && $_SERVER['TERM_PROGRAM'] == 'Apple_Terminal' || isset($_ENV['TERM_PROGRAM']) && $_ENV['TERM_PROGRAM'] == 'Apple_Terminal') && version_compare(preg_replace('/^ProductVersion:\\s*([0-9]+\\.[0-9]+)/ms', '$1', shell_exec('sw_vers')), '10.5', 'eq') && !Phing::getProperty('phing.logger.defaults')) { Phing::setProperty('phing.logger.defaults', new PhingFile(BUILD_DIRECTORY . '/agavi/phing/ansicolorlogger_osxleopard.properties')); } elseif (stripos(PHP_OS, 'Win') === 0) { $GLOBALS['LOGGER'] = 'phing.listener.DefaultLogger'; } $GLOBALS['LOGGER'] = Phing::import($GLOBALS['LOGGER']); $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);
/** * Copies the configuration from the proxied project into this project. * * @author Noah Fontes <*****@*****.**> * @since 1.0.4 */ protected function copy() { foreach ($this->proxied->getBuildListeners() as $listener) { parent::addBuildListener($listener); } $this->setInputHandler($this->proxied->getInputHandler()); foreach ($this->proxied->getTaskDefinitions() as $name => $class) { parent::addTaskDefinition($name, $class); } foreach ($this->proxied->getDataTypeDefinitions() as $name => $class) { parent::addDataTypeDefinition($name, $class); } /* Assign properties for consistency. */ $this->proxied->copyUserProperties($this); $this->proxied->copyInheritedProperties($this); foreach ($this->proxied->getProperties() as $name => $property) { if (!AgaviProxyProject::isPropertyProtected($name) && $this->getProperty($name) === null) { parent::setNewProperty($name, $property); } } /* Add proxy targets to the new project. */ foreach ($this->proxied->getTargets() as $name => $target) { $proxy = new AgaviProxyTarget(); $proxy->setName($name); $proxy->setDescription($target->getDescription()); $proxy->setTarget($target); parent::addTarget($name, $proxy); } parent::setUserProperty('phing.version', $this->proxied->getProperty('phing.version')); $this->setSystemProperties(); }