use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class ZipUtil method preserveModificationTimes.
/**
* Preserve modification time of files and directories in a zip file. If a directory is not an
* entry in the zip file and reproducible timestamps are enabled then its modification timestamp
* is set to a constant value.
*
* @param destination target root for unzipping
* @param entries list of entries in zip file
* @param enableReproducibleTimestamps whether or not reproducible timestamps should be used
* @throws IOException when I/O error occurs
*/
private static void preserveModificationTimes(Path destination, List<ZipEntry> entries, boolean enableReproducibleTimestamps) throws IOException {
if (enableReproducibleTimestamps) {
FileTime epochPlusOne = FileTime.fromMillis(1000L);
new DirectoryWalker(destination).filter(Files::isDirectory).walk(path -> Files.setLastModifiedTime(path, epochPlusOne));
}
for (ZipEntry entry : entries) {
Files.setLastModifiedTime(destination.resolve(entry.getName()), entry.getLastModifiedTime());
}
}
use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class GradleProjectProperties method getClassFiles.
@Override
public List<Path> getClassFiles() throws IOException {
// TODO: Consolidate with createJibContainerBuilder
FileCollection classesOutputDirectories = getMainSourceSet().getOutput().getClassesDirs().filter(File::exists);
List<Path> classFiles = new ArrayList<>();
for (File classesOutputDirectory : classesOutputDirectories) {
classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk());
}
return classFiles;
}
Aggregations