@VisibleForTesting
  static void writeFileConservatively(Path file, String content) throws IOException {
    if (Files.exists(file)) {
      String oldContent = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
      if (oldContent.equals(content)) {
        return;
      }
    }
    Files.createDirectories(file.getParent());
    Files.write(file, content.getBytes(StandardCharsets.UTF_8));
  }
Writes a file only when needed (when the file does not exist or the existing file has a
different content). It reads the entire bytes into a {@code String} for content comparison, so
care should be taken when using this method for a huge file.

@param file target file to write
@param content file content to write
@throws IOException if file I/O error
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java