Java Code Examples for org.codehaus.plexus.util.DirectoryScanner#setFollowSymlinks()

The following examples show how to use org.codehaus.plexus.util.DirectoryScanner#setFollowSymlinks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractImpSortMojo.java    From impsort-maven-plugin with Apache License 2.0 6 votes vote down vote up
private Stream<File> searchDir(File dir, boolean warnOnBadDir) {
  if (dir == null || !dir.exists() || !dir.isDirectory()) {
    if (warnOnBadDir && dir != null) {
      getLog().warn("Directory does not exist or is not a directory: " + dir);
    }
    return Stream.empty();
  }
  getLog().debug("Adding directory " + dir);
  DirectoryScanner ds = new DirectoryScanner();
  ds.setBasedir(dir);
  ds.setIncludes(includes != null && includes.length > 0 ? includes : DEFAULT_INCLUDES);
  ds.setExcludes(excludes);
  ds.addDefaultExcludes();
  ds.setCaseSensitive(false);
  ds.setFollowSymlinks(false);
  ds.scan();
  return Stream.of(ds.getIncludedFiles()).map(filename -> new File(dir, filename)).parallel();
}
 
Example 2
Source File: FormatterMojo.java    From formatter-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Add source files to the files list.
 *
 */
List<File> addCollectionFiles(File newBasedir) {
    final DirectoryScanner ds = new DirectoryScanner();
    ds.setBasedir(newBasedir);
    if (this.includes != null && this.includes.length > 0) {
        ds.setIncludes(this.includes);
    } else {
        ds.setIncludes(DEFAULT_INCLUDES);
    }

    ds.setExcludes(this.excludes);
    ds.addDefaultExcludes();
    ds.setCaseSensitive(false);
    ds.setFollowSymlinks(false);
    ds.scan();

    List<File> foundFiles = new ArrayList<>();
    for (String filename : ds.getIncludedFiles()) {
        foundFiles.add(new File(newBasedir, filename));
    }
    return foundFiles;
}
 
Example 3
Source File: FormatMojo.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private List<File> scan(File directory) {
	DirectoryScanner scanner = new DirectoryScanner();
	scanner.setBasedir(directory);
	scanner.setIncludes(hasLength(this.includes) ? this.includes : DEFAULT_INCLUDES);
	scanner.setExcludes(this.excludes);
	scanner.addDefaultExcludes();
	scanner.setCaseSensitive(false);
	scanner.setFollowSymlinks(false);
	scanner.scan();
	return Arrays.asList(scanner.getIncludedFiles()).stream().map(name -> new File(directory, name))
			.collect(Collectors.toList());
}