Example #1
0
 /**
  * add a name entry on the include list
  * @return PatternSetNameEntry
  */
 public function createInclude()
 {
     return $this->fileset->createInclude();
 }
 /**
  * {@inheritdoc}
  *
  * @throws BuildException
  * @throws IOException
  */
 public function main()
 {
     if ($this->dir == null) {
         throw new BuildException("missing dir");
     }
     if ($this->name == null) {
         throw new BuildException("missing name");
     }
     if ($this->pathRefId == null) {
         throw new BuildException("missing pathrefid");
     }
     if (!$this->dir->isDirectory()) {
         throw new BuildException($this->dir->toString() . " is not a directory");
     }
     $path = $this->getProject()->getReference($this->pathRefId);
     if ($path == null) {
         throw new BuildException("Unknown reference " . $this->pathRefId);
     }
     if (!$path instanceof Path) {
         throw new BuildException($this->pathRefId . " is not a path");
     }
     $sources = $path->listPaths();
     $fileSet = new FileSet();
     $fileSet->setProject($this->getProject());
     $fileSet->setDir($this->dir);
     $fileUtils = new FileUtils();
     $dirNormal = $fileUtils->normalize($this->dir->getAbsolutePath());
     $dirNormal = rtrim($dirNormal, PhingFile::$separator) . PhingFile::$separator;
     $atLeastOne = false;
     for ($i = 0; $i < count($sources); ++$i) {
         $sourceFile = new PhingFile($sources[$i]);
         if (!$sourceFile->exists()) {
             continue;
         }
         $includePattern = $this->getIncludePattern($dirNormal, $sourceFile);
         if ($includePattern === false && !$this->ignoreNonRelative) {
             throw new BuildException($sources[$i] . " is not relative to " . $this->dir->getAbsolutePath());
         }
         if ($includePattern === false) {
             continue;
         }
         $fileSet->createInclude()->setName($includePattern);
         $atLeastOne = true;
     }
     if (!$atLeastOne) {
         $fileSet->createInclude()->setName("a:b:c:d//THis si &&& not a file !!! ");
     }
     $this->getProject()->addReference($this->name, $fileSet);
 }