Interface FileManifest

All Known Implementing Classes:
MockManifest

public interface FileManifest
Creates and tracks the files generated by a SmithyBuildPlugin. Mutating FileManifest implementations MUST be thread-safe as they can be used concurrently across multiple threads when building models.
  • Method Details

    • create

      static FileManifest create(Path basePath)
      Create a default file manifest for the given base path.
      Parameters:
      basePath - Base path where files are written.
      Returns:
      Returns the created manifest.
    • getBaseDir

      Path getBaseDir()
      Gets the base directory of the manifest.
      Returns:
      Returns the base directory.
    • getFiles

      Set<Path> getFiles()
      Gets all of the files in the result.

      The order of files returned should be stable across calls.

      Returns:
      Returns the files in the manifest.
    • addFile

      Path addFile(Path path)
      Adds a path to the manifest.

      The given path must be relative or within the base directory.

      Parameters:
      path - Path to add.
      Returns:
      Returns the path resolved against any base URL.
    • addAllFiles

      default void addAllFiles(FileManifest manifest)
      Adds the files from another FileManifest into this FileManifest.
      Parameters:
      manifest - Other object to merge with.
    • resolvePath

      default Path resolvePath(Path path)
      Resolves a path against the base path of the manifest.
      Parameters:
      path - Path to resolve against the base URL.
      Returns:
      Returns the resolved, absolute path.
      Throws:
      SmithyBuildException - if the resolved path cannot falls outside of the base URL of the manifest.
    • writeFile

      Path writeFile(Path path, Reader fileContentsReader)
      Adds a file to the result using the contents of a Reader.

      This method will write the contents of a Reader to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsReader - Reader to consume and write to the file.
      Returns:
      Returns the resolved path.
    • writeFile

      Path writeFile(Path path, InputStream fileContentsInputStream)
      Adds a file to the result using the contents of an InputStream.

      This method will write the contents of an input stream to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsInputStream - InputStream to consume and write to the file.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(Path path, Class klass, String resource)
      Adds a file to the result using the contents of a resource loaded by calling Class.getResourceAsStream(String).

      This method should be preferred when writing class resources to the manifest since it handles closing the created InputStream and avoids tripping up tools like SpotBugs.

      Parameters:
      path - Relative path to the file to create.
      klass - Class to load the resource from.
      resource - Path to the resource to load.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(String path, Class klass, String resource)
      Adds a file to the result using the contents of a resource loaded by calling Class.getResourceAsStream(String).
      Parameters:
      path - Relative path to the file to create.
      klass - Class to load the resource from.
      resource - Path to the resource to load.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(Path path, String fileContentsText)
      Adds a UTF-8 encoded file to the result.

      This method will write the contents of a string to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsText - String value to write to the file.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(String path, String fileContentsText)
      Adds a UTF-8 encoded file to the result.

      This method will write the contents of a string to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsText - String value to write to the file.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(String path, Reader fileContentsReader)
      Adds a file to the result using the contents of a Reader.

      This method will write the contents of a Reader to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsReader - Reader to consume and write to the file.
      Returns:
      Returns the resolved path.
    • writeFile

      default Path writeFile(String path, InputStream fileContentsInputStream)
      Adds a file to the result using the contents of an InputStream.

      This method will write the contents of an input stream to a file.

      Parameters:
      path - Relative path to the file to create.
      fileContentsInputStream - InputStream to consume and write to the file.
      Returns:
      Returns the resolved path.
    • writeJson

      default Path writeJson(Path path, Node node)
      Adds a Node artifact, converting it automatically to JSON.
      Parameters:
      path - Relative path to write to.
      node - Node data to write to JSON.
      Returns:
      Returns the resolved path.
    • writeJson

      default Path writeJson(String path, Node node)
      Adds a Node artifact, converting it automatically to JSON.
      Parameters:
      path - Relative path to write to.
      node - Node data to write to JSON.
      Returns:
      Returns the resolved path.
    • hasFile

      default boolean hasFile(Path file)
      Checks if the given file is stored in the manifest.
      Parameters:
      file - File to check.
      Returns:
      Return true if the file exists in the manifest.
    • hasFile

      default boolean hasFile(String file)
      Checks if the given file is stored in the manifest.
      Parameters:
      file - File to check.
      Returns:
      Return true if the file exists in the manifest.
    • getFilesIn

      default List<Path> getFilesIn(Path path)
      Gets the paths to files stored under a prefix.
      Parameters:
      path - Path prefix.
      Returns:
      Returns the matching file paths in sorted order.
    • getFilesIn

      default List<Path> getFilesIn(String path)
      Gets the paths to files stored under a prefix.
      Parameters:
      path - Path prefix.
      Returns:
      Returns the matching file paths.