in src/main/java/org/apache/maven/buildcache/CacheUtils.java [175:200]
public static boolean zip(final Path dir, final Path zip, final String glob) throws IOException {
final MutableBoolean hasFiles = new MutableBoolean();
try (ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(zip))) {
PathMatcher matcher =
"*".equals(glob) ? null : FileSystems.getDefault().getPathMatcher("glob:" + glob);
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes)
throws IOException {
if (matcher == null || matcher.matches(path.getFileName())) {
final ZipEntry zipEntry =
new ZipEntry(dir.relativize(path).toString());
zipOutputStream.putNextEntry(zipEntry);
Files.copy(path, zipOutputStream);
hasFiles.setTrue();
zipOutputStream.closeEntry();
}
return FileVisitResult.CONTINUE;
}
});
}
return hasFiles.booleanValue();
}