Example #1
0
 public function main()
 {
     if (NULL === $this->filesets) {
         throw new \BuildException('No fileset provided');
     }
     $project = new Project(new Phing($this));
     $project->addListener($listener = new PhingListener($this));
     $analyzers = NULL !== $this->getConfigFile() ? require $this->getConfigFile() : Project::getDefaultConfig();
     $project->addAnalyzers($analyzers);
     # Add files
     foreach ($this->filesets as $fs) {
         $ds = $fs->getDirectoryScanner($this->project);
         /** @var \PhingFile $fromDir */
         $fromDir = $fs->getDir($this->project);
         /** @var  $files */
         $files = $ds->getIncludedFiles();
         foreach ($files as $file) {
             $fileName = $fromDir->getAbsolutePath() . DIRECTORY_SEPARATOR . $file;
             $this->log('Adding file ' . $fileName, \Project::MSG_VERBOSE);
             $project->addSplFileInfo(new \SplFileInfo($fileName));
         }
     }
     $project->analyze();
     $buildErrorMessage = $listener->getBuildErrorMessage();
     if ($this->haltonerror && !empty($buildErrorMessage)) {
         throw new \BuildException($buildErrorMessage);
     }
 }