File (@NotNull File jarFile, @NotNull File root) { try (ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(jarFile))) { FileUtil.visitFiles(root, file -> { if (file.isFile()) { String path = FileUtil.toSystemIndependentName(Objects.requireNonNull(FileUtil.getRelativePath(root, file))); try { stream.putNextEntry(new ZipEntry(path)); try (InputStream is = new FileInputStream(file)) { FileUtil.copy(is, stream); } stream.closeEntry(); } catch (IOException e) { throw new RuntimeException(e); } } return true; }); return jarFile; } catch (IOException e) { throw new RuntimeException(e); } }