/** * 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. * * @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); } } }
/** * 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(); }