/** * 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); }
/* 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); $size = 0;