本文整理汇总了PHP中ProjectConfigurator::configureProject方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectConfigurator::configureProject方法的具体用法?PHP ProjectConfigurator::configureProject怎么用?PHP ProjectConfigurator::configureProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectConfigurator
的用法示例。
在下文中一共展示了ProjectConfigurator::configureProject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Executes this target.
*/
public function main()
{
if ($this->name === null) {
throw new BuildException('The name attribute must be specified');
}
/* Words cannot describe how ridiculously fucking 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. Fuck. */
$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);
}
}
/* Fuck. */
unset($project);
}
示例2: main
/**
* @return void
* @throws \BuildException
*/
public function main()
{
if (realpath($this->pathToChainFolder) === false) {
throw new \BuildException('invalid path to chain folder');
}
foreach ($this->chains as $chain) {
$file = new \PhingFile($this->pathToChainFolder . '/' . $chain . '.xml');
\ProjectConfigurator::configureProject($this->project, $file);
}
}
示例3: main
/**
* 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);
}
示例4: runBuild
/**
* Executes the build.
* @return void
*/
function runBuild()
{
if (!$this->readyToRun) {
return;
}
$project = new Project();
self::setCurrentProject($project);
set_error_handler(array('Phing', 'handlePhpError'));
$error = null;
$this->addBuildListeners($project);
$this->addInputHandler($project);
// set this right away, so that it can be used in logging.
$project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());
try {
$project->fireBuildStarted();
$project->init();
} catch (Exception $exc) {
$project->fireBuildFinished($exc);
throw $exc;
}
$project->setUserProperty("phing.version", $this->getPhingVersion());
$e = self::$definedProps->keys();
while (count($e)) {
$arg = (string) array_shift($e);
$value = (string) self::$definedProps->getProperty($arg);
$project->setUserProperty($arg, $value);
}
unset($e);
$project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());
// first use the Configurator to create the project object
// from the given build file.
try {
ProjectConfigurator::configureProject($project, $this->buildFile);
} catch (Exception $exc) {
$project->fireBuildFinished($exc);
restore_error_handler();
self::unsetCurrentProject();
throw $exc;
}
// make sure that we have a target to execute
if (count($this->targets) === 0) {
$this->targets[] = $project->getDefaultTarget();
}
// make sure that minimum required phing version is satisfied
try {
$this->comparePhingVersion($project->getPhingVersion());
} catch (Exception $exc) {
$project->fireBuildFinished($exc);
restore_error_handler();
self::unsetCurrentProject();
throw $exc;
}
// execute targets if help param was not given
if (!$this->projectHelp) {
try {
$project->executeTargets($this->targets);
} catch (Exception $exc) {
$project->fireBuildFinished($exc);
restore_error_handler();
self::unsetCurrentProject();
throw $exc;
}
}
// if help is requested print it
if ($this->projectHelp) {
try {
$this->printDescription($project);
$this->printTargets($project);
} catch (Exception $exc) {
$project->fireBuildFinished($exc);
restore_error_handler();
self::unsetCurrentProject();
throw $exc;
}
}
// finally {
if (!$this->projectHelp) {
$project->fireBuildFinished(null);
}
restore_error_handler();
self::unsetCurrentProject();
}
示例5: processFile
/**
* 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.");
}
}
示例6: configureProject
/**
* set up to run the named project
*
* @param filename name of project file to run
* @throws BuildException
*/
protected function configureProject($filename)
{
$this->logBuffer = "";
$this->fullLogBuffer = "";
$this->project = new Project();
$this->project->init();
$f = new PhingFile($filename);
$this->project->setUserProperty("phing.file", $f->getAbsolutePath());
$this->project->addBuildListener(new PhingTestListener($this));
ProjectConfigurator::configureProject($this->project, new PhingFile($filename));
}
示例7: importFile
/**
* Parse a Phing build file and copy the properties, tasks, data types and
* targets it defines into the current project.
*
* @throws BuildException
* @return void
*/
protected function importFile(PhingFile $file)
{
$ctx = $this->project->getReference("phing.parsing.context");
$cfg = $ctx->getConfigurator();
// Import xml file into current project scope
// Since this is delayed until after the importing file has been
// processed, the properties and targets of this new file may not take
// effect if they have alreday been defined in the outer scope.
$this->log("Importing file from {$file->getAbsolutePath()}", Project::MSG_VERBOSE);
ProjectConfigurator::configureProject($this->project, $file);
}
示例8: main
/**
* Parse a Phing build file and copy the properties, tasks, data types and
* targets it defines into the current project.
*
* @return void
*/
public function main()
{
if (!isset($this->file)) {
throw new BuildException("Missing attribute 'file'");
}
$file = new PhingFile($this->file);
if (!$file->isAbsolute()) {
$file = new PhingFile($this->project->getBasedir(), $this->file);
}
if (!$file->exists()) {
$msg = "Unable to find build file: {$file->getPath()}";
if ($this->optional) {
$this->log($msg . '... skipped');
return;
} else {
throw new BuildException($msg);
}
}
$ctx = $this->project->getReference("phing.parsing.context");
$cfg = $ctx->getConfigurator();
if (null !== $cfg && $cfg->isParsing()) {
// because there isn't a top level implicit target in phing like there is
// in Ant 1.6, we will be called as soon as our xml is parsed. This isn't
// really what we want to have happen. Instead we will register ourself
// with the parse context to be called at the end of the current file's
// parse phase.
$cfg->delayTaskUntilParseEnd($this);
} else {
// Import xml file into current project scope
// Since this is delayed until after the importing file has been
// processed, the properties and targets of this new file may not take
// effect if they have alreday been defined in the outer scope.
$this->log("Importing configuration from {$file->getName()}", Project::MSG_VERBOSE);
ProjectConfigurator::configureProject($this->project, $file);
$this->log("Configuration imported.", Project::MSG_VERBOSE);
}
}
示例9: main
/**
* Parse a Phing build file and copy the properties, tasks, data types and
* targets it defines into the current project.
*
* @throws BuildException
* @return void
*/
public function main()
{
if (!isset($this->file)) {
throw new BuildException("Missing attribute 'file'");
}
if ($this->getOwningTarget() == null || $this->getOwningTarget()->getName() != '') {
throw new BuildException("import only allowed as a top-level task");
}
$file = new PhingFile($this->file);
if (!$file->isAbsolute()) {
$file = new PhingFile($this->project->getBasedir(), $this->file);
}
if (!$file->exists()) {
$msg = "Unable to find build file: {$file->getPath()}";
if ($this->optional) {
$this->log($msg . '... skipped');
return;
} else {
throw new BuildException($msg);
}
}
$ctx = $this->project->getReference("phing.parsing.context");
$cfg = $ctx->getConfigurator();
// Import xml file into current project scope
// Since this is delayed until after the importing file has been
// processed, the properties and targets of this new file may not take
// effect if they have alreday been defined in the outer scope.
$this->log("Importing file from {$file->getAbsolutePath()}", Project::MSG_VERBOSE);
ProjectConfigurator::configureProject($this->project, $file);
}
示例10: AgaviProxyBuildLogger
$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 fucks 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;
$targets = array();
foreach ($project->getTargets() as $target) {
$name = $target->getName();
$nameSize = strlen($name);
$description = $target->getDescription();
if ($description !== null) {
$size = $nameSize > $size ? $nameSize : $size;
$targets[$name] = $description;
}