use of org.codehaus.plexus.util.DirectoryScanner in project sling by apache.
the class CreateBundleJarMojo method getFilesToCopy.
/**
* Returns a list of filenames that should be copied over to the destination
* directory.
*
* @param resource
* the resource to be scanned
* @return the array of filenames, relative to the sourceDir
*/
private static String[] getFilesToCopy(Resource resource) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(resource.getDirectory());
if (resource.getIncludes() != null && !resource.getIncludes().isEmpty()) {
scanner.setIncludes(resource.getIncludes().toArray(new String[resource.getIncludes().size()]));
} else {
scanner.setIncludes(DEFAULT_INCLUDES);
}
if (resource.getExcludes() != null && !resource.getExcludes().isEmpty()) {
scanner.setExcludes(resource.getExcludes().toArray(new String[resource.getExcludes().size()]));
}
scanner.addDefaultExcludes();
scanner.scan();
return scanner.getIncludedFiles();
}
use of org.codehaus.plexus.util.DirectoryScanner in project sling by apache.
the class JspcMojo method scanFiles.
/**
* Locate all jsp files in the webapp. Used if no explicit jsps are
* specified.
*/
private void scanFiles(File base) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(base);
scanner.setIncludes(includes);
scanner.setExcludes(excludes);
scanner.scan();
Collections.addAll(pages, scanner.getIncludedFiles());
}
use of org.codehaus.plexus.util.DirectoryScanner in project felix by apache.
the class BundlePlugin method getMavenResourcePaths.
protected static String getMavenResourcePaths(MavenProject currentProject, boolean test) {
final String basePath = currentProject.getBasedir().getAbsolutePath();
Set<String> pathSet = new LinkedHashSet<String>();
for (Iterator<Resource> i = getMavenResources(currentProject, test).iterator(); i.hasNext(); ) {
Resource resource = i.next();
final String sourcePath = resource.getDirectory();
final String targetPath = resource.getTargetPath();
// ignore empty or non-local resources
if (new File(sourcePath).exists() && ((targetPath == null) || (targetPath.indexOf("..") < 0))) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(sourcePath);
if (resource.getIncludes() != null && !resource.getIncludes().isEmpty()) {
scanner.setIncludes(resource.getIncludes().toArray(EMPTY_STRING_ARRAY));
} else {
scanner.setIncludes(DEFAULT_INCLUDES);
}
if (resource.getExcludes() != null && !resource.getExcludes().isEmpty()) {
scanner.setExcludes(resource.getExcludes().toArray(EMPTY_STRING_ARRAY));
}
scanner.addDefaultExcludes();
scanner.scan();
List<String> includedFiles = Arrays.asList(scanner.getIncludedFiles());
for (Iterator<String> j = includedFiles.iterator(); j.hasNext(); ) {
String name = j.next();
String path = sourcePath + '/' + name;
// make relative to project
if (path.startsWith(basePath)) {
if (path.length() == basePath.length()) {
path = ".";
} else {
path = path.substring(basePath.length() + 1);
}
}
// this is a workaround for a problem with bnd 0.0.189
if (File.separatorChar != '/') {
name = name.replace(File.separatorChar, '/');
path = path.replace(File.separatorChar, '/');
}
// copy to correct place
path = name + '=' + path;
if (targetPath != null) {
path = targetPath + '/' + path;
}
// use Bnd filtering?
if (resource.isFiltering()) {
path = '{' + path + '}';
}
pathSet.add(path);
}
}
}
StringBuffer resourcePaths = new StringBuffer();
for (Iterator<String> i = pathSet.iterator(); i.hasNext(); ) {
resourcePaths.append(i.next());
if (i.hasNext()) {
resourcePaths.append(',');
}
}
return resourcePaths.toString();
}
use of org.codehaus.plexus.util.DirectoryScanner in project fabric8 by jboss-fuse.
the class AddSwaggerAnnotationMojo method scan.
/**
* Scans a single directory.
*
* @param root Directory to scan
* @throws MojoExecutionException in case of IO errors
*/
private void scan(File root) throws MojoExecutionException {
if (!root.exists()) {
return;
}
final DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setIncludes(includes);
directoryScanner.setExcludes(excludes);
directoryScanner.setBasedir(root);
directoryScanner.scan();
for (String fileName : directoryScanner.getIncludedFiles()) {
final File file = new File(root, fileName);
try {
processJavaFile(file);
} catch (Exception e) {
throw new MojoExecutionException("io error while rewriting source file", e);
}
}
}
use of org.codehaus.plexus.util.DirectoryScanner in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _shouldConfigure.
/**
* IDE-1489 when no liferay maven plugin is found the project will be scanned
* for liferay specific files
*/
private boolean _shouldConfigure(Plugin liferayMavenPlugin, ProjectConfigurationRequest request) {
IProject project = request.getProject();
MavenProject mavenProject = request.getMavenProject();
boolean configureAsLiferayPlugin = false;
if (liferayMavenPlugin != null) {
configureAsLiferayPlugin = true;
}
IFolder warSourceDir = _warSourceDirectory(project, mavenProject);
if (!configureAsLiferayPlugin && (warSourceDir != null)) {
IPath baseDir = warSourceDir.getRawLocation();
String[] includes = { "**/liferay*.xml", "**/liferay*.properties" };
DirectoryScanner dirScanner = new DirectoryScanner();
dirScanner.setBasedir(baseDir.toFile());
dirScanner.setIncludes(includes);
dirScanner.scan();
String[] liferayProjectFiles = dirScanner.getIncludedFiles();
configureAsLiferayPlugin = ListUtil.isNotEmpty(liferayProjectFiles);
}
return configureAsLiferayPlugin;
}
Aggregations