Example #1
0
 public static function tests_tasks()
 {
     $exec = new Build_BuilderElement_Task_Exec();
     $exec->setExecutable('ls');
     $exec->setArgs(array('-la'));
     $exec->setBaseDir('/tmp/');
     //$exec->setOutputProperty('xpto');
     //echo $exec->toString('ant');
     $delete = new Build_BuilderElement_Task_Filesystem_Delete();
     $delete->setIncludeEmptyDirs(true);
     $delete->setFailOnError(true);
     $fileset = new Build_BuilderElement_Type_Fileset();
     $fileset->setDir('/tmp/apache');
     //$fileset->setDefaultExcludes(false);
     $fileset->setInclude(array('extra/**/*.conf'));
     $delete->setFilesets(array($fileset));
     //echo $delete->toString('ant');
     $echo = new Build_BuilderElement_Task_Echo();
     $echo->setMessage('Ol�');
     $echo->setFile('${workDir}/ixo.txt');
     $echo2 = new Build_BuilderElement_Task_Echo();
     $echo2->setMessage('About to do an exec2!');
     $echo2->setFile('/tmp/test.log');
     $echo2->setAppend(true);
     $mkdir = new Build_BuilderElement_Task_Filesystem_Mkdir();
     //$mkdir->setDir('/tmp/tmp2/tmp3');
     $mkdir->setDir('${dir}');
     $lint = new Build_BuilderElement_Task_Php_PhpLint();
     $lint->setFilesets(array($fileset));
     $chmod = new Build_BuilderElement_Task_Filesystem_Chmod();
     $chmod->setMode('${perms}');
     $chmod->setFile('${file}');
     //$chmod->setFilesets(array($fileset));
     $chown = new Build_BuilderElement_Task_Filesystem_Chown();
     $chown->setFile('/tmp/lixo1.php');
     $chown->setUser('www-data');
     $copy = new Build_BuilderElement_Task_Filesystem_Copy();
     $copy->setFile('/tmp/src/config/cintient.conf.php');
     $copy->setToDir('${toDir}');
     $perl = new Build_BuilderElement_Task_Perl_PerlSyntax();
     $fs2 = new Build_BuilderElement_Type_Fileset();
     $fs2->setDir('/tmp/');
     $fs2->setInclude(array('**/*pl'));
     $perl->setFilesets(array($fs2));
     /*$fileset = new Build_BuilderElement_Type_Fileset();
         $fileset->setDir('${dir}');
         $fileset->setInclude(array('${include}'));
     
         $fileset->setType(Build_BuilderElement_Type_Fileset::BOTH);
         $copy->setFilesets(array($fileset));
     		*/
     $properties = new Build_BuilderElement_Type_Properties();
     $properties->setText("workDir = /tmp/\ntitle = Cintient\nexecutable = ls\nargs = -la\ndir = /tmp/src/\nfile = /tmp/lixo1.php\nperms = 755\ninclude = **/*\ntoDir = /tmp/src2/\n");
     $rr = new Build_BuilderElement_Task_ReplaceRegexp();
     $rr->setFile('/tmp/whatevs.txt');
     //$rr->setFilesets(array($fileset));
     $rr->setFlags('gmi');
     $rr->setReplace('asd$1');
     $rr->setMatch('/^ola"asd(.*)$/');
     $target = new Build_BuilderElement_Target();
     $target->setName('tests');
     $target->setTasks(array($rr));
     //echo $target->toString('php');
     $target2 = new Build_BuilderElement_Target();
     $target2->setName('tests2');
     //$target->setTasks(array($delete, $exec));
     $target2->setTasks(array($echo, $rr));
     //echo $target->toString('php');
     $project = new Build_BuilderElement_Project();
     $project->addTarget($target);
     $project->setBaseDir('/tmp/');
     //$project->addTarget($target2);
     $project->setDefaultTarget($target->getName());
     $code = $project->toPhp();
     echo $code;
     //var_dump(BuilderConnector_Php::execute($code));
     exit;
 }
Example #2
0
 /**
  * Call this at the very creation of the project, for checking out the sources
  * and initialization stuff like that.
  */
 public function init()
 {
     //
     // Create all the working directories
     //
     $this->setWorkDir(CINTIENT_PROJECTS_DIR . uniqid($this->getId(), true) . '/');
     // Don't forget the trailing '/'!
     if (!@mkdir($this->getWorkDir(), DEFAULT_DIR_MASK, true)) {
         $this->setWorkDir(null);
         SystemEvent::raise(SystemEvent::ERROR, "Could not create working root dir for project. [PID={$this->getId()}]", __METHOD__);
         return false;
     }
     if (!file_exists($this->getScmLocalWorkingCopy())) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not create sources dir for project. [PID={$this->getId()}]", __METHOD__);
         return false;
     }
     if (!file_exists($this->getReportsWorkingDir())) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not create reports dir for project. [PID={$this->getId()}]", __METHOD__);
         return false;
     }
     if (!file_exists($this->getReleasesDir())) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not create releases dir for project. [PID={$this->getId()}]", __METHOD__);
         return false;
     }
     //
     // Setup the minimal integration builder setup
     //
     $echo = new Build_BuilderElement_Task_Echo();
     $echo->setMessage("hello, world");
     $target = new Build_BuilderElement_Target();
     $target->setName('build');
     $this->_integrationBuilder->addTarget($target);
     $this->_integrationBuilder->setDefaultTarget($target->getName());
     $this->setDefaultPropertiesForIntegrationBuilder();
     $this->addToIntegrationBuilder($echo);
     //
     // Save the project and take care of all database dependencies.
     //
     if (!$this->_save()) {
         return false;
     }
     if (!Project_Log::install($this)) {
         $this->delete();
         return false;
     }
     if (!Project_Build::install($this)) {
         $this->delete();
         return false;
     }
     $this->setStatus(self::STATUS_UNINITIALIZED);
     return true;
 }