@VisibleForTesting
  static String getProjectCacheDirectoryFromProject(Path path) {
    try {
      byte[] hashedBytes =
          MessageDigest.getInstance("SHA-256")
              .digest(path.toFile().getCanonicalPath().getBytes(Charsets.UTF_8));
      StringBuilder stringBuilder = new StringBuilder(2 * hashedBytes.length);
      for (byte b : hashedBytes) {
        stringBuilder.append(String.format("%02x", b));
      }
      return stringBuilder.toString();
    } catch (IOException | SecurityException ex) {
      throw new RuntimeException(
          "Unable to create cache directory for project path: "
              + path
              + " - you can try to configure --project-cache manually",
          ex);
    } catch (NoSuchAlgorithmException ex) {
      throw new RuntimeException(
          "SHA-256 algorithm implementation not found - might be a broken JVM");
    }
  }
Create a caches helper for cli cache locations.

@param commonCliOptions cli options for user configured cache directories
@param contextRoot the context root, use the parent directory of single files, this context
    root must exist
@return an instance of CacheDirectories with cli specific cache locations
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CacheDirectories.java