use of java.nio.file.PathMatcher in project jetty.project by eclipse.
the class CorrectMavenCentralRefs method fix.
public void fix(Path buildRoot) throws IOException {
// Find all of the *.mod files
PathFinder finder = new PathFinder();
finder.setFileMatcher("glob:**/*.mod");
finder.setBase(buildRoot);
// Matcher for target directories
PathMatcher targetMatcher = PathMatchers.getMatcher("glob:**/target/**");
PathMatcher testMatcher = PathMatchers.getMatcher("glob:**/test/**");
System.out.printf("Walking path: %s%n", buildRoot);
Set<FileVisitOption> options = Collections.emptySet();
Files.walkFileTree(buildRoot, options, 30, finder);
System.out.printf("Found: %d hits%n", finder.getHits().size());
int count = 0;
for (Path path : finder.getHits()) {
if (Files.isDirectory(path)) {
// skip
continue;
}
if (targetMatcher.matches(path)) {
// skip
continue;
}
if (testMatcher.matches(path)) {
// skip
continue;
}
if (processModFile(path)) {
count++;
}
}
System.out.printf("Processed %,d modules", count);
}
use of java.nio.file.PathMatcher in project jetty.project by eclipse.
the class RebuildTestResources method copyXmls.
private void copyXmls() throws IOException {
System.out.println("Copying xmls (etc dir) ...");
Path xmlDir = destDir.resolve("etc");
FS.ensureDirExists(xmlDir.toFile());
PathMatcher matcher = getPathMatcher("glob:**.xml");
Renamer renamer = new NoRenamer();
FileCopier copier = new TouchFileCopier();
copyDir(srcDir.resolve("etc"), xmlDir, matcher, renamer, copier);
}
use of java.nio.file.PathMatcher in project jetty.project by eclipse.
the class RebuildTestResources method copyModules.
private void copyModules() throws IOException {
System.out.println("Copying modules ...");
Path modulesDir = destDir.resolve("modules");
FS.ensureDirExists(modulesDir.toFile());
PathMatcher matcher = getPathMatcher("glob:**.mod");
Renamer renamer = new NoRenamer();
FileCopier copier = new NormalFileCopier();
copyDir(srcDir.resolve("modules"), modulesDir, matcher, renamer, copier);
}
use of java.nio.file.PathMatcher in project jetty.project by eclipse.
the class RebuildTestResources method copyLibs.
private void copyLibs() throws IOException {
System.out.println("Copying libs (lib dir) ...");
Path libsDir = destDir.resolve("lib");
FS.ensureDirExists(libsDir.toFile());
PathMatcher matcher = getPathMatcher("glob:**.jar");
Renamer renamer = new RegexRenamer("-9\\.[0-9.]*(v[0-9-]*)?(-SNAPSHOT)?(RC[0-9])?(M[0-9])?", "-" + JETTY_VERSION);
FileCopier copier = new TouchFileCopier();
copyDir(srcDir.resolve("lib"), libsDir, matcher, renamer, copier);
}
use of java.nio.file.PathMatcher in project elasticsearch by elastic.
the class IngestGeoIpPlugin method loadDatabaseReaders.
static Map<String, DatabaseReaderLazyLoader> loadDatabaseReaders(Path geoIpConfigDirectory, NodeCache cache) throws IOException {
if (Files.exists(geoIpConfigDirectory) == false && Files.isDirectory(geoIpConfigDirectory)) {
throw new IllegalStateException("the geoip directory [" + geoIpConfigDirectory + "] containing databases doesn't exist");
}
Map<String, DatabaseReaderLazyLoader> databaseReaders = new HashMap<>();
try (Stream<Path> databaseFiles = Files.list(geoIpConfigDirectory)) {
PathMatcher pathMatcher = geoIpConfigDirectory.getFileSystem().getPathMatcher("glob:**.mmdb.gz");
// Use iterator instead of forEach otherwise IOException needs to be caught twice...
Iterator<Path> iterator = databaseFiles.iterator();
while (iterator.hasNext()) {
Path databasePath = iterator.next();
if (Files.isRegularFile(databasePath) && pathMatcher.matches(databasePath)) {
String databaseFileName = databasePath.getFileName().toString();
DatabaseReaderLazyLoader holder = new DatabaseReaderLazyLoader(databaseFileName, () -> {
try (InputStream inputStream = new GZIPInputStream(Files.newInputStream(databasePath, StandardOpenOption.READ))) {
return new DatabaseReader.Builder(inputStream).withCache(cache).build();
}
});
databaseReaders.put(databaseFileName, holder);
}
}
}
return Collections.unmodifiableMap(databaseReaders);
}
Aggregations