code: public static List<File> scanDirectoryForFiles(BuildContext buildContext, final File directory,
  			final String[] includes, final String[] excludes, boolean defaultExcludes) throws IOException {
  		if (!directory.exists()) {
  			return Collections.emptyList();
  		}
  		final Scanner scanner;
  
  		if (buildContext != null) {
  			scanner = buildContext.newScanner(directory, true);
  		} else {
  			final DirectoryScanner directoryScanner = new DirectoryScanner();
  			directoryScanner.setBasedir(directory.getAbsoluteFile());
  			scanner = directoryScanner;
  		}
  		scanner.setIncludes(includes);
  		scanner.setExcludes(excludes);
  		if (defaultExcludes) {
  			scanner.addDefaultExcludes();
  		}
  
  		scanner.scan();
  
  		final List<File> files = new ArrayList<File>();
  		for (final String name : scanner.getIncludedFiles()) {
  			files.add(new File(directory, name).getCanonicalFile());
  		}
  
  		return files;
  	}
docs: Scans given directory for files satisfying given inclusion/exclusion
  patterns.
  
  @param buildContext
  Build context provided by the environment, used to scan for files.
  @param directory
  Directory to scan.
  @param includes
  inclusion pattern.
  @param excludes
  exclusion pattern.
  @param defaultExcludes
  default exclusion flag.
  @return Files from the given directory which satisfy given patterns. The
  files are {@link File#getCanonicalFile() canonical}.
  @throws IOException
  If an I/O error occurs, which is possible because the
  construction of the canonical pathname may require filesystem
  queries.