private static void preserveModificationTimes(
      Path destination, List<TarArchiveEntry> 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 (TarArchiveEntry entry : entries) {

      // Setting the symbolic link's modification timestamp will cause the modification timestamp of
      // the target to change
      if (!entry.isSymbolicLink()) {
        Files.setLastModifiedTime(
            destination.resolve(entry.getName()), FileTime.from(entry.getModTime().toInstant()));
      }
    }
  }
Preserve modification timestamps of files and directories in a tar file. If a directory is not
an entry in the tar file and reproducible timestamps are enabled then its modification
timestamp is set to a constant value. Note that the modification timestamps of symbolic links
are not preserved even with reproducible timestamps enabled.

@param destination target root for unzipping
@param entries list of entries in tar file
@param enableReproducibleTimestamps whether or not reproducible timestamps should be used
@throws IOException when I/O error occurs
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java