Пример #1
0
 public function testLogging()
 {
     $project = new Xinc_Project();
     $name = 'test ' . rand(21213, 123213);
     $project->setName($name);
     $message = 'info ' . rand(3123123, 123123213);
     $project->info($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'debug ' . rand(3123123, 123123213);
     $project->debug($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'warn ' . rand(3123123, 123123213);
     $project->warn($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'error ' . rand(3123123, 123123213);
     $project->error($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_VERBOSE);
     $message = 'verbose ' . rand(3123123, 123123213);
     ob_start();
     $project->verbose($message);
     $contents = ob_get_clean();
     $lastMsg = Xinc_StreamLogger::getLastLogMessage();
     Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG);
     $this->assertTrue(strpos($lastMsg, $message) !== false, 'Last message should contain message');
     //$this->assertEquals($lastMsg, $contents,
     //                 'Last message should contain message');
 }
Пример #2
0
 public function validateTask()
 {
     if (!isset($this->fileName)) {
         Xinc_Logger::getInstance()->error('File must be specified for artifactspublisher.');
         return false;
     }
     return true;
 }
Пример #3
0
 public function validateTask()
 {
     if (null === $this->fileName || null === $this->index || null === $this->alias) {
         Xinc_Logger::getInstance()->error('File, Index and Alias must be specified for documentation publisher.');
         return false;
     }
     return true;
 }
Пример #4
0
 public function validateTask()
 {
     if (null === $this->fileName) {
         Xinc_Logger::getInstance()->error('File must be specified for deliverable publisher.');
         return false;
     }
     return true;
 }
Пример #5
0
 /**
  * Validates if a task can run by checking configs, directries and so on.
  *
  * @return boolean Is true if task can run.
  */
 public function validate()
 {
     try {
         return $this->validateTask();
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error('Could not validate: ' . $e->getMessage());
         return false;
     }
 }
Пример #6
0
 public function setUp()
 {
     Xinc_Logger::tearDown();
     $this->sharedFixture = Xinc_Logger::getInstance();
     $this->sharedFixture->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG);
     try {
         $this->sharedFixture->setXincLogFile("xinclogger://test");
         $this->sharedFixture->setBuildLogFile("xinclogger://test");
     } catch (Exception $e) {
         var_dump($e);
     }
 }
Пример #7
0
 /**
  * Validate if all information the task needs to run properly have been set
  *
  * @return boolean True if task can be started otherwise false.
  */
 public function validateTask()
 {
     // validate if buildfile exists
     // try in working dir
     $buildFileWorking = $this->workingDir . DIRECTORY_SEPARATOR . $this->buildFile;
     if (!file_exists($this->buildFile) && !file_exists($buildFileWorking)) {
         Xinc_Logger::getInstance()->error('Build-File ' . $this->buildFile . ' does not exist');
         return false;
     } elseif (file_exists($buildFileWorking)) {
         $this->buildFile = $buildFileWorking;
     }
     return true;
 }
Пример #8
0
 /**
  * Parses the projects xml
  * loads all the tasks
  * assigns them to the builds
  *
  * @param Xinc\Core\Project\Iterator $projects
  *
  * @return array the builds
  */
 public function parseProjectOld($project)
 {
     $builds = array();
     //         $this->setters = Xinc_Plugin_Repository::getInstance()
     //             ->getTasksForSlot(Xinc_Plugin_Slot::PROJECT_SET_VALUES);
     $build = null;
     /**
      * trying to recover the last build information
      */
     try {
         $build = \Xinc\Core\Build::unserialize($project);
         $build->setBuildTime(null);
         $build->resetConfigDirective();
     } catch (Xinc_Build_Exception_NotFound $e) {
         Xinc_Logger::getInstance()->info('No status data found for ' . $project->getName());
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error('Could not unserialize old status of ' . $project->getName());
     }
     $projectXml = $project->getConfig();
     if (!$build instanceof Xinc_Build_Interface) {
         $build = new Xinc_Build($this->engine, $project);
     }
     $build->getProperties()->set('project.name', $project->getName());
     $build->getProperties()->set('build.number', $build->getNumber());
     $build->getProperties()->set('build.label', $build->getLabel());
     $builtinProps = Xinc::getInstance()->getBuiltinProperties();
     foreach ($builtinProps as $prop => $value) {
         $build->getProperties()->set($prop, $value);
     }
     $taskRegistry = new Xinc_Build_Tasks_Registry();
     $this->_parseTasks($build, $projectXml, $taskRegistry);
     $build->setTaskRegistry($taskRegistry);
     $build->process(Xinc_Plugin_Slot::PROJECT_INIT);
     if (!$build->haveScheduler()) {
         // set default scheduler
         $scheduler = new Xinc_Build_Scheduler_Default();
         $build->addScheduler($scheduler);
     }
     $labeler = $build->getLabeler();
     if ($labeler == null) {
         // set default scheduler
         $labeler = new Xinc_Build_Labeler_Default();
         $build->setLabeler($labeler);
     }
     $builds[] = $build;
     return $builds;
 }
Пример #9
0
 /**
  * Validate if all information the task needs to run
  * properly have been set
  *
  * @return boolean
  */
 public function validateTask()
 {
     // validate if buildfile exists
     // try in working dir
     $workingdir = Xinc::getInstance()->getWorkingDir();
     $file2 = $workingdir . DIRECTORY_SEPARATOR . $this->_buildFile;
     $file = $this->_buildFile;
     if (!file_exists($file) && !file_exists($file2)) {
         Xinc_Logger::getInstance()->error('Build-File ' . $file . ' does not exist');
         return false;
     } else {
         if (file_exists($file2)) {
             $this->_buildFile = $file2;
         }
     }
     return true;
 }
Пример #10
0
 /**
  * Enter description here...
  *
  * @param SimpleXMLElement $pluginXml
  *
  * @throws Xinc_Plugin_Exception_FileNotFound
  * @throws Xinc_Plugin_Exception_ClassNotFound
  * @throws Xinc_Plugin_Exception_Invalid
  * @throws Xinc_Plugin_Task_Exception
  */
 private static function loadPlugin(SimpleXMLElement $pluginXml)
 {
     $plugins = array();
     $attributes = $pluginXml->attributes();
     Xinc_Logger::getInstance()->info('Registering plugin: ' . $attributes->classname . ' from file ' . $attributes->filename);
     $res = (include_once (string) $attributes->filename);
     if (!$res && !class_exists((string) $attributes->classname)) {
         throw new Xinc_Plugin_Exception_FileNotFound((string) $attributes->classname, (string) $attributes->filename);
     }
     if (!class_exists((string) $attributes->classname)) {
         throw new Xinc_Plugin_Exception_ClassNotFound((string) $attributes->classname, (string) $attributes->filename);
     }
     $classname = (string) $attributes->classname;
     $plugin = new $classname();
     if (!$plugin instanceof Xinc_Plugin_Interface) {
         throw new Xinc_Plugin_Exception_Invalid((string) $attributes->classname);
     }
     Xinc_Plugin_Repository::getInstance()->registerPlugin($plugin);
 }
Пример #11
0
 /**
  * Generates statistsics and saves them into the build.
  *
  * @param Xinc_Build_Interface $build      The actuall build.
  * @param string               $sourceFile The xml file to read stats from.
  *
  * @return boolean True if registering was ok, false if it failed.
  */
 public function generateStats(Xinc_Build_Interface $build, $file)
 {
     try {
         /**
          * @var string Contains content of the XML file
          */
         $strContent = file_get_contents($file);
         if ('' !== $strContent) {
             $arStats = $this->parseXml($strContent);
             /**
              * set the statistics data
              */
             foreach ($arStats as $strName => $mValue) {
                 $build->getStatistics()->set('checkstyle.' . $strName, $mValue);
             }
         }
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error('Could not parse checkstyle xml: ' . $e->getMessage() . "\n" . 'Trace: ' . $e->getTraceAsString());
         return false;
     }
     return true;
 }
Пример #12
0
 /**
  * Process a build
  *
  * @param Xinc_Build_Interface $build
  */
 public function build(Xinc_Build_Interface $build)
 {
     /**
      * handles the configuration of this build and sets all the options
      */
     $this->handleBuildConfig($build);
     $this->build = $build;
     $buildTime = time();
     $startTime = microtime(true);
     $build->setBuildTime($buildTime);
     $build->init();
     if (Xinc_Build_Interface::STOPPED === $build->getStatus()) {
         return $this->endBuild();
     }
     /**
      * Increasing the build number, if it fails we need to decrease again
      */
     if (Xinc_Build_Interface::PASSED === $build->getLastBuild()->getStatus() || null === $build->getLastBuild()->getStatus() && Xinc_Build_Interface::STOPPED !== $build->getLastBuild()->getStatus()) {
         $build->setNumber($build->getNumber() + 1);
         //$this->updateBuildTasks($build);
     }
     $build->updateTasks();
     $build->process(Xinc_Plugin_Slot::INIT_PROCESS);
     if (Xinc_Build_Interface::STOPPED === $build->getStatus()) {
         Xinc_Logger::getInstance()->info('Build of Project stopped in INIT phase');
         $build->setLastBuild();
         return $this->endBuild();
     }
     Xinc_Logger::getInstance()->info('CHECKING PROJECT ' . $build->getProject()->getName());
     $build->process(Xinc_Plugin_Slot::PRE_PROCESS);
     if (Xinc_Build_Interface::STOPPED === $build->getStatus()) {
         $build->info('Build of Project stopped, no build necessary');
         $build->setStatus(Xinc_Build_Interface::INITIALIZED);
         $build->setLastBuild();
         return $this->endBuild();
     } elseif (Xinc_Build_Interface::FAILED === $build->getStatus()) {
         //$build->setBuildTime($buildTime);
         $build->updateTasks();
         $build->error("Build failed");
         /**
          * Process failed in the pre-process phase, we need
          * to run post-process to maybe inform about the failed build
          */
         $build->process(Xinc_Plugin_Slot::POST_PROCESS);
         /**
          * Issue 79, we need to serialize the build after failure in preprocess
          */
         /**
          * set the "time it took to build" on the build
          */
         $endTime = microtime(true);
         $build->getStatistics()->set('build.duration', $endTime - $startTime);
         $this->serializeBuild($build);
         return $this->endBuild();
     } elseif (Xinc_Build_Interface::PASSED === $build->getStatus()) {
         $build->info('Code not up to date, building project');
         $build->updateTasks();
         $build->process(Xinc_Plugin_Slot::PROCESS);
         if (Xinc_Build_Interface::PASSED == $build->getStatus()) {
             $build->updateTasks();
             $build->info("BUILD PASSED");
         } elseif (Xinc_Build_Interface::STOPPED == $build->getStatus()) {
             //$build->setNumber($build->getNumber()-1);
             $build->updateTasks();
             $build->warn("BUILD STOPPED");
         } elseif (Xinc_Build_Interface::FAILED == $build->getStatus()) {
             //if ($build->getLastBuild()->getStatus() == Xinc_Build_Interface::PASSED) {
             //    $build->setNumber($build->getNumber()+1);
             //}
             $build->updateTasks();
             $build->error("BUILD FAILED");
         }
         $processingPast = $build->getStatus();
         /**
          * Post-Process is run on Successful and Failed Builds
          */
         $build->process(Xinc_Plugin_Slot::POST_PROCESS);
         /**
          * set the "time it took to build" on the build
          */
         $endTime = microtime(true);
         $build->getStatistics()->set('build.duration', $endTime - $startTime);
         $this->serializeBuild($build);
         return $this->endBuild();
     } elseif (Xinc_Build_Interface::INITIALIZED === $build->getStatus()) {
         //$build->setBuildTime($buildTime);
         if ($build->getLastBuild()->getStatus() === null) {
             $build->setNumber($build->getNumber() - 1);
         }
         $build->setStatus(Xinc_Build_Interface::STOPPED);
         $this->serializeBuild($build);
         return $this->endBuild();
     } else {
         $build->setStatus(Xinc_Build_Interface::STOPPED);
         $build->setLastBuild();
         return $this->endBuild();
     }
 }
Пример #13
0
 /**
  * calling phing
  *
  * @param Xinc_Build_Interface $build
  * @param string $buildfile
  * @param string $target
  * @param string $extraParams
  * @param string $workingDir
  *
  * @return boolean
  */
 public function build(Xinc_Build_Interface $build, $buildfile, $target, $extraParams = null, $workingDir = null)
 {
     //$phing = new Phing();
     $logLevel = Xinc_Logger::getInstance()->getLogLevel();
     $arguments = array();
     switch ($logLevel) {
         case Xinc_Logger::LOG_LEVEL_VERBOSE:
             $arguments[] = '-verbose';
             break;
     }
     $oldPwd = getcwd();
     /**
      * set workingdir if not set from task,
      * use project dir
      */
     if ($workingDir == null) {
         $workingDir = Xinc::getInstance()->getProjectDir() . DIRECTORY_SEPARATOR . $build->getProject()->getName();
     }
     if (is_dir($workingDir)) {
         Xinc_Logger::getInstance()->debug('Switching to directory: ' . $workingDir);
         chdir($workingDir);
     }
     $logFile = getcwd() . DIRECTORY_SEPARATOR . md5($build->getProject()->getName() . time()) . '.log';
     if (file_exists($logFile)) {
         unlink($logFile);
     }
     $arguments[] = '-logger';
     //$arguments[] = 'phing.listener.DefaultLogger';
     $arguments[] = 'phing.listener.NoBannerLogger';
     $arguments[] = '-logfile';
     $arguments[] = $logFile;
     $arguments[] = '-buildfile';
     $arguments[] = $buildfile;
     if ($target != null) {
         $arguments[] = $target;
     }
     $arguments[] = '-Dxinc.buildlabel=' . $this->_encodeParam($build->getLabel());
     $arguments[] = '-Dprojectname=' . $this->_encodeParam($build->getProject()->getName());
     $arguments[] = '-Dcctimestamp=' . $this->_encodeParam($build->getBuildTime());
     foreach ($build->getProperties()->getAllProperties() as $name => $value) {
         $arguments[] = '-Dxinc.' . $this->_encodeParam($name) . '=' . $this->_encodeParam($value);
     }
     try {
         $phingPath = Xinc_Ini::getInstance()->get('path', 'phing');
     } catch (Exception $e) {
         $phingPath = null;
     }
     if (empty($phingPath)) {
         if (DIRECTORY_SEPARATOR != '/') {
             /**
              * windows has the phing command inside the bin_dir directory
              */
             $phingPath = PEAR_Config::singleton()->get('bin_dir') . DIRECTORY_SEPARATOR . 'phing';
         } else {
             $phingPath = 'phing';
         }
     }
     if (DIRECTORY_SEPARATOR == '/') {
         $redirect = "2>&1";
     } else {
         $redirect = "";
     }
     $command = $phingPath . ' ' . implode(' ', $arguments) . ' ' . $extraParams . ' ' . $redirect;
     exec($command, $output, $returnValue);
     chdir($oldPwd);
     $buildSuccess = false;
     if (file_exists($logFile)) {
         $fh = fopen($logFile, 'r');
         if (is_resource($fh)) {
             while ($line = fgets($fh)) {
                 Xinc_Logger::getInstance()->info($line);
                 if (strstr($line, "BUILD FINISHED")) {
                     $buildSuccess = true;
                 }
             }
             fclose($fh);
         }
         unlink($logFile);
     }
     if (count($output) > 0) {
         Xinc_Logger::getInstance()->error('Errors on command line:');
         foreach ($output as $line) {
             Xinc_Logger::getInstance()->error($line);
         }
     }
     switch ($returnValue) {
         case 0:
         case 1:
             if ($buildSuccess) {
                 return true;
             } else {
                 $build->error('Phing command ' . $command . ' exited with status: ' . $returnValue);
                 $build->setStatus(Xinc_Build_Interface::FAILED);
                 return false;
             }
             break;
         case -1:
         case -2:
             $build->error('Phing build script: ' . $command . ' exited with status: ' . $returnValue);
             $build->setStatus(Xinc_Build_Interface::FAILED);
             return false;
             break;
     }
     return false;
 }
Пример #14
0
 /**
  * Migrates old history files ( which had all data in one file)
  * to new history files (which use one meta file, and several
  * smaller data files)
  *
  * @param string $projectName
  * @param array $arr
  * @throws Xinc_Build_History_Exception_MetaFile
  * @throws Xinc_Build_History_Exception_Migration
  */
 private static function _migrate($projectName, array $arr)
 {
     if (empty($projectName)) {
         throw new Xinc_Build_History_Exception_Migration();
     }
     $metaFileName = self::_getMetaFileName($projectName);
     if (!is_readable($metaFileName)) {
         throw new Xinc_Build_History_Exception_MetaFile('MetaFile "' . $metaFileName . '" is not readable');
     }
     copy($metaFileName, $metaFileName . '.backup');
     $counter = 0;
     $fileNo = 0;
     $part = array();
     $i = 0;
     $totalCount = count($arr);
     $metaArr = array('meta' => true, 'parts' => array());
     foreach ($arr as $timestamp => $fileName) {
         $part[$timestamp] = $fileName;
         $i++;
         if (++$counter >= self::PART_MAX || $i >= $totalCount) {
             $no = $fileNo;
             try {
                 $statusFile = self::_writePartFile($projectName, $fileNo++, $part);
             } catch (Xinc_Build_History_Exception_Storage $e1) {
                 Xinc_Logger::getInstance()->error('Cannot write build history file for ' . $project->getName());
                 $statusFile = null;
             }
             $keys = array_keys($part);
             $metaArr['parts'][] = array('filename' => $statusFile, 'from' => $keys[0], 'to' => $keys[count($keys) - 1], 'count' => count($keys), 'no' => $no);
             $part = array();
             $counter = 0;
         }
     }
     try {
         self::_writeMetaData($projectName, $metaArr);
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error($e->getMessage());
     }
 }
Пример #15
0
 /**
  *  Fired whenever a message is logged.
  *
  *  @param BuildEvent The BuildEvent
  *
  *  @see BuildEvent::getMessage()
  */
 public function messageLogged(BuildEvent $event)
 {
     $logger = Xinc_Logger::getInstance();
     /**
      * write to a temporary logfile
      * - which will be read afterwards and the logentries will
      * - be used to determine the status of the build
      */
     switch ($event->getPriority()) {
         case self::MSG_DEBUG:
         case self::MSG_VERBOSE:
             $logger->debug('[phing] ' . $event->getMessage());
             break;
         case self::MSG_INFO:
             $logger->info('[phing] ' . $event->getMessage());
             break;
         case self::MSG_WARN:
             $logger->warn('[phing] ' . $event->getMessage());
             break;
         case self::MSG_ERR:
             $logger->error('[phing] ' . $event->getMessage());
             Xinc::getCurrentBuild()->setStatus(Xinc_Build_Interface::FAILED);
             break;
     }
     $exception = $event->getException();
     if ($exception != null) {
         $logger->error('[phing] ' . $exception->getMessage());
         Xinc::getCurrentBuild()->setStatus(Xinc_Build_Interface::FAILED);
     }
 }
Пример #16
0
 /**
  * Check necessary variables are set
  *
  * @throws Xinc_Exception_MalformedConfig
  */
 public function validate()
 {
     if (DIRECTORY_SEPARATOR == '/') {
         // we are on Linux/Unix
         $redirectErrors = ' 2>&1';
     } else {
         $redirectErrors = ' ';
     }
     exec($this->_svnPath . ' help' . $redirectErrors, $output, $result);
     /**
      * See Issue 56, check r
      */
     if ($result != 0) {
         Xinc_Logger::getInstance()->error('command "svn" not found');
         return false;
     } else {
         return true;
     }
 }
Пример #17
0
 /**
  * Validates if a task can run by checking configs, directries and so on.
  *
  * @return boolean Is true if task can run.
  */
 public function validateTask()
 {
     if (!isset($this->_directory)) {
         throw new Xinc_Exception_MalformedConfig('Element modificationSet/svntag - required attribute "directory" is not set');
     }
     if (!isset($this->_prefix)) {
         throw new Xinc_Exception_MalformedConfig('Element modificationSet/svntag - required attribute "prefix" is not set');
     }
     $file = $this->_directory;
     $file2 = Xinc::getInstance()->getWorkingDir() . DIRECTORY_SEPARATOR . $file;
     if (!file_exists($file) && !file_exists($file2)) {
         Xinc_Logger::getInstance()->error('Directory ' . $file2 . ' does not exist');
         return false;
     } elseif (file_exists($file2)) {
         $this->_directory = $file2;
     }
     return true;
 }
Пример #18
0
 private function setConfigDirective($name, $value)
 {
     $this->config[$name] = $value;
     switch ($name) {
         case 'loglevel':
             Xinc_Logger::getInstance()->setLogLevel($value);
             break;
         case 'timezone':
             Xinc_Timezone::set($value);
             break;
         default:
     }
 }
Пример #19
0
 /**
  * Validate if the plugin can run properly on this system
  *
  * @return boolean True if plugin can run properly otherwise false.
  */
 public function validate()
 {
     if (!@(include_once 'VersionControl/SVN.php')) {
         Xinc_Logger::getInstance()->error('PEAR:VersionControl_SVN not installed.');
         return false;
     }
     return true;
 }
Пример #20
0
 public function getTestResults(Xinc_Build_Interface $build)
 {
     require_once 'PEAR/Config.php';
     $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir();
     $projectName = $build->getProject()->getName();
     $buildTimestamp = $build->getBuildTime();
     $buildLabel = $build->getLabel();
     $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'phpunit-summary.phtml');
     $template = file_get_contents($templateFile);
     $url = '/phpunit/results/?project=' . $projectName . '&buildtime=' . $buildTimestamp . '&f=results.html';
     $sourceFile = $build->getInternalProperties()->get('phpunit.file');
     if ($sourceFile != null && file_exists($sourceFile) && class_exists('XSLTProcessor')) {
         $xslFile = Xinc_Data_Repository::getInstance()->getPlugins('resources' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'summary.xsl');
         try {
             $outputFileName = Xinc_Ini::getInstance()->get('tmp_dir', 'xinc') . DIRECTORY_SEPARATOR . 'phpunit_summary_' . $projectName . '_' . $buildTimestamp;
         } catch (Exception $e) {
             Xinc_Logger::getInstance()->error('Cannot get xinc.ini configuration');
             $outputFileName = 'phpunit_summary_' . $projectName . '_' . $buildTimestamp;
         }
         if (file_exists($outputFileName)) {
             $summary = file_get_contents($outputFileName);
         } else {
             $summary = $this->_transformResults($sourceFile, $xslFile, $outputFileName);
         }
         //$click = 'openMenuTab(\'phpunit-'.$projectName.'-'.$buildTimestamp.'\',\'PHPUnit - '.$projectName.'\',\''.$url.'\',null,false,false,\'auto\');';
         $detailsLink = '<a href="' . $url . '">Details</a>';
         $content = str_replace(array('{detailsLink}', '{summary}'), array($detailsLink, $summary), $template);
     } else {
         $content = false;
     }
     return $content;
 }
Пример #21
0
 /**
  * Determines the Widget that should be used
  * for the specified Http-Request by the Pathname that 
  * is called
  *
  * @param String $path Pathname of the HTTP-Request
  *
  * @return Xinc_Gui_Widget_Interface
  */
 public function &getWidgetForPath($path)
 {
     Xinc_Logger::getInstance()->info('Getting widget for path: ' . $path);
     $widget = null;
     if (!isset($this->definedWidgets[$path])) {
         // find the largest match
         $largest = 0;
         foreach ($this->definedWidgets as $pathReg => $widgetItem) {
             if (($match = strstr($path, $pathReg)) !== false && strpos($path, $pathReg) == 0) {
                 if (strlen($pathReg) > $largest) {
                     $largest = strlen($pathReg);
                     $widget = $widgetItem;
                 }
             }
         }
     } else {
         $widget = $this->definedWidgets[$path];
     }
     return $widget;
 }
Пример #22
0
 /**
  * Validates if a task can run by checking configs, directries and so on.
  *
  * @return boolean Is true if task can run.
  */
 public function validateTask()
 {
     if (!class_exists('VersionControl_SVN')) {
         throw new Xinc_Exception_MalformedConfig('PEAR::VersionControl_SVN doesn\'t exists. You need to install it to use this task.');
     }
     if (!isset($this->strDirectory)) {
         throw new Xinc_Exception_MalformedConfig('Element modificationSet/svn - required attribute "directory" is not set.');
     }
     $file = $this->strDirectory;
     $file2 = Xinc::getInstance()->getWorkingDir() . DIRECTORY_SEPARATOR . $file;
     if (!file_exists($file) && !file_exists($file2)) {
         Xinc_Logger::getInstance()->error('Directory ' . $file2 . ' does not exist.');
         return false;
     } elseif (file_exists($file2)) {
         $this->strDirectory = $file2;
     }
     return true;
 }
Пример #23
0
 /**
  * Add a projectfile to the xinc processing.
  *
  * @param string $fileName
  */
 private function addProjectFile($fileName)
 {
     try {
         $config = new Xinc_Project_Config($fileName);
         $engineName = $config->getEngineName();
         $engine = Xinc_Engine_Repository::getInstance()->getEngine($engineName);
         $builds = $engine->parseProjects($config->getProjects());
         self::$_buildQueue->addBuilds($builds);
     } catch (Xinc_Project_Config_Exception_FileNotFound $notFound) {
         Xinc_Logger::getInstance()->error('Project Config File ' . $fileName . ' cannot be found');
     } catch (Xinc_Project_Config_Exception_InvalidEntry $invalid) {
         Xinc_Logger::getInstance()->error('Project Config File has an invalid entry: ' . $invalid->getMessage());
     } catch (Xinc_Engine_Exception_NotFound $engineNotFound) {
         Xinc_Logger::getInstance()->error('Project Config File references an unknown Engine: ' . $engineNotFound->getMessage());
     }
 }
Пример #24
0
 /**
  * Logs a message of priority error
  *
  * @param string $message
  */
 public function error($message)
 {
     Xinc_Logger::getInstance()->error('[project] ' . $this->getName() . ': ' . $message);
 }
Пример #25
0
 public function build()
 {
     Xinc_Logger::getInstance()->setBuildLogFile(null);
     Xinc_Logger::getInstance()->emptyLogQueue();
     Xinc::setCurrentBuild($this);
     $buildLogFile = Xinc::getInstance()->getStatusDir() . DIRECTORY_SEPARATOR . $this->getProject()->getName() . DIRECTORY_SEPARATOR . 'buildlog.xml';
     if (file_exists($buildLogFile)) {
         self::info('Removing old logfile "' . $buildLogFile . '" with size: ' . filesize($buildLogFile));
         unlink($buildLogFile);
     }
     Xinc_Logger::getInstance()->setBuildLogFile($buildLogFile);
     $this->getEngine()->build($this);
     //Xinc_Logger::getInstance()->flush();
     Xinc_Logger::getInstance()->setBuildLogFile(null);
     if (Xinc_Build_Interface::STOPPED != $this->getStatus()) {
         $this->setStatus(Xinc_Build_Interface::INITIALIZED);
     }
 }