public static FileEntriesLayer getDirectoryContentsAsLayer(
      String layerName,
      Path sourceRoot,
      Predicate<Path> pathFilter,
      AbsoluteUnixPath basePathInContainer)
      throws IOException {
    FileEntriesLayer.Builder builder = FileEntriesLayer.builder().setName(layerName);
    new DirectoryWalker(sourceRoot)
        .filterRoot()
        .filter(path -> pathFilter.test(path))
        .walk(
            path -> {
              AbsoluteUnixPath pathOnContainer =
                  basePathInContainer.resolve(sourceRoot.relativize(path));
              builder.addEntry(path, pathOnContainer);
            });
    return builder.build();
  }
Creates a layer containing contents of a directory. Only paths that match the given predicate
will be added.

@param layerName name of the layer
@param sourceRoot path to source directory
@param pathFilter predicate to determine whether to add the path or not
@param basePathInContainer path to destination on container
@return {@link FileEntriesLayer} representing the layer
@throws IOException if io exception occurs when reading from the source directory
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactLayers.java