/** * Returns the directory scanner needed to access the files to process. * @return DirectoryScanner */ protected function getDirectoryScanner(PhingFile $baseDir) { $this->fileset->setDir($baseDir); $this->fileset->setDefaultexcludes($this->useDefaultExcludes); return $this->fileset->getDirectoryScanner($this->project); }
/** * @param FileSet $fs * @throws BuildException */ protected function processFileSet(FileSet $fs) { $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); $fullPath = realpath($fs->getDir($this->project)); foreach ($files as $file) { $this->log('Minifying file ' . $file); try { $target = $this->targetDir . '/' . str_replace($fullPath, '', str_replace('.js', $this->suffix . '.js', $file)); if (file_exists(dirname($target)) === false) { mkdir(dirname($target), 0777 - umask(), true); } $contents = file_get_contents($fullPath . '/' . $file); // nasty hack to not trip PHP 5.2 parser $minified = forward_static_call(array('\\JShrink\\Minifier', 'minify'), $contents); file_put_contents($target, $minified); } catch (Exception $jsme) { $this->log("Could not minify file {$file}: " . $jsme->getMessage(), Project::MSG_ERR); } } }