public static String buildManifest(Path inputs, boolean required) throws IOException {
    StringBuilder result = new StringBuilder();

    List<Resource> sortedResources = inputs.stream()
      .sorted(Comparator.comparing(Resource::toString))
      .collect(Collectors.toList());

    for (Resource resource : sortedResources) {
      if (!(resource instanceof FileResource)) {
        throw new BuildException("Only FileResource resources are supported: " + resource.toLongString());
      }

      java.nio.file.Path path = ((FileResource) resource).getFile().toPath();
      if (!Files.exists(path)) {
        if (required) {
          throw new BuildException("Required file or directory is missing on disk: " + path);
        }
        else {
          result.append(resource).append(": missing\n");
        }
      }
      else {
        if (Files.isDirectory(path)) {
          try (Stream<java.nio.file.Path> pathStream = Files.walk(path, FileVisitOption.FOLLOW_LINKS)) {
            pathStream
              .sorted(java.nio.file.Path::compareTo)
              .filter(p -> !Files.isDirectory(p))
              .forEach(p -> recordFile(result, p));
          }
        }
        else {
          recordFile(result, path);
        }
      }
    }

    return result.toString();
  }
public static String buildManifest(Path inputs, boolean required)