/** * Prints warning message to screen if -debug was used. */ function warn($msg) { if (Phing::getMsgOutputLevel() === PROJECT_MSG_DEBUG) { print "[IntrospectionHelper] " . $msg . "\n"; } }
/** * Execute phing file. * * @return void */ private function processFile() { $buildFailed = false; $savedDir = $this->dir; $savedPhingFile = $this->phingFile; $savedTarget = $this->newTarget; $savedBasedirAbsPath = null; // this is used to save the basedir *if* we change it try { if ($this->newProject === null) { $this->reinit(); } $this->initializeProject(); if ($this->dir !== null) { $dirAbsPath = $this->dir->getAbsolutePath(); // BE CAREFUL! -- when the basedir is changed for a project, // all calls to getAbsolutePath() on a relative-path dir will // be made relative to the project's basedir! This means // that subsequent calls to $this->dir->getAbsolutePath() will be WRONG! // We need to save the current project's basedir first. $savedBasedirAbsPath = $this->getProject()->getBasedir()->getAbsolutePath(); $this->newProject->setBasedir($this->dir); // Now we must reset $this->dir so that it continues to resolve to the same // path. $this->dir = new PhingFile($dirAbsPath); if ($savedDir !== null) { // has been set explicitly $this->newProject->setInheritedProperty("project.basedir", $this->dir->getAbsolutePath()); } } else { // Since we're not changing the basedir here (for file resolution), // we don't need to worry about any side-effects in this scanrio. $this->dir = $this->getProject()->getBasedir(); } $this->overrideProperties(); if ($this->phingFile === null) { $this->phingFile = "build.xml"; } $fu = new FileUtils(); $file = $fu->resolveFile($this->dir, $this->phingFile); $this->phingFile = $file->getAbsolutePath(); $this->log("Calling Buildfile '" . $this->phingFile . "' with target '" . $this->newTarget . "'"); $this->newProject->setUserProperty("phing.file", $this->phingFile); ProjectConfigurator::configureProject($this->newProject, new PhingFile($this->phingFile)); if ($this->newTarget === null) { $this->newTarget = $this->newProject->getDefaultTarget(); } // Are we trying to call the target in which we are defined? if ($this->newProject->getBaseDir() == $this->project->getBaseDir() && $this->newProject->getProperty("phing.file") == $this->project->getProperty("phing.file") && $this->getOwningTarget() !== null && $this->newTarget == $this->getOwningTarget()->getName()) { throw new BuildException("phing task calling its own parent target"); } $this->addReferences(); $this->newProject->executeTarget($this->newTarget); } catch (Exception $e) { $buildFailed = true; $this->log($e->getMessage(), Project::MSG_ERR); if (Phing::getMsgOutputLevel() <= Project::MSG_DEBUG) { $lines = explode("\n", $e->getTraceAsString()); foreach ($lines as $line) { $this->log($line, Project::MSG_DEBUG); } } // important!!! continue on to perform cleanup tasks. } // reset environment values to prevent side-effects. $this->newProject = null; $pkeys = array_keys($this->properties); foreach ($pkeys as $k) { $this->properties[$k]->setProject(null); } $this->dir = $savedDir; $this->phingFile = $savedPhingFile; $this->newTarget = $savedTarget; // If the basedir for any project was changed, we need to set that back here. if ($savedBasedirAbsPath !== null) { chdir($savedBasedirAbsPath); } if ($this->haltOnFailure && $buildFailed) { throw new BuildException("Execution of the target buildfile failed. Aborting."); } }
/** * Prints warning message to screen if -debug was used. * @param string $msg */ public function warn($msg) { if (Phing::getMsgOutputLevel() === Project::MSG_DEBUG) { print "[IntrospectionHelper] " . $msg . "\n"; } }