in twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java [304:333]
private void copyDir(File baseDir, String entryPrefix,
Set<String> entries, JarOutputStream jarOut) throws IOException {
LOG.trace("adding whole dir {} to bundle at '{}'", baseDir, entryPrefix);
URI baseUri = baseDir.toURI();
Queue<File> queue = Lists.newLinkedList();
queue.add(baseDir);
while (!queue.isEmpty()) {
File file = queue.remove();
String entry = entryPrefix + baseUri.relativize(file.toURI()).getPath();
if (entries.add(entry)) {
jarOut.putNextEntry(new JarEntry(entry));
if (file.isFile()) {
try {
Files.copy(file, jarOut);
} catch (IOException e) {
throw new IOException("failure copying from " + file.getAbsoluteFile() + " to JAR file entry " + entry, e);
}
}
jarOut.closeEntry();
}
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
Collections.addAll(queue, files);
}
}
}
}