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