public function setUp() { $this->configureProject(PHING_TEST_BASE . "/etc/components/Target/Target.xml"); $this->target = new Target(); $this->target->setProject($this->project); $this->target->setName('MyTarget'); }
/** * Adds or replaces a target in the project * @param string $targetName * @param Target $target */ public function addOrReplaceTarget($targetName, &$target) { $this->log(" +Target: {$targetName}", Project::MSG_DEBUG); $target->setProject($this); $this->targets[$targetName] = $target; $ctx = $this->getReference("phing.parsing.context"); $current = $ctx->getCurrentTargets(); $current[$targetName] = $target; }
/** * Creates the ExpatParser, sets root handler and kick off parsing * process. * * @throws BuildException if there is any kind of execption during * the parsing process */ protected function parse() { try { // get parse context $ctx = $this->project->getReference("phing.parsing.context"); if (null == $ctx) { // make a new context and register it with project $ctx = new PhingXMLContext($this->project); $this->project->addReference("phing.parsing.context", $ctx); } //record this parse with context $ctx->addImport($this->buildFile); if (count($ctx->getImportStack()) > 1) { $currentImplicit = $ctx->getImplicitTarget(); $currentTargets = $ctx->getCurrentTargets(); $newCurrent = new Target(); $newCurrent->setProject($this->project); $newCurrent->setName(''); $ctx->setCurrentTargets(array()); $ctx->setImplicitTarget($newCurrent); // this is an imported file // modify project tag parse behavior $this->setIgnoreProjectTag(true); $this->_parse($ctx); $newCurrent->main(); $ctx->setImplicitTarget($currentImplicit); $ctx->setCurrentTargets($currentTargets); } else { $ctx->setCurrentTargets(array()); $this->_parse($ctx); $ctx->getImplicitTarget()->main(); } } catch (Exception $exc) { //throw new BuildException("Error reading project file", $exc); throw $exc; } }