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 Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void addAllFiles​(FileManifest manifest)
      Adds the files from another FileManifest into this FileManifest.
      java.nio.file.Path addFile​(java.nio.file.Path path)
      Adds a path to the manifest.
      static FileManifest create​(java.nio.file.Path basePath)
      Create a default file manifest for the given base path.
      java.nio.file.Path getBaseDir()
      Gets the base directory of the manifest.
      java.util.Set<java.nio.file.Path> getFiles()
      Gets all of the files in the result.
      default java.util.List<java.nio.file.Path> getFilesIn​(java.lang.String path)
      Gets the paths to files stored under a prefix.
      default java.util.List<java.nio.file.Path> getFilesIn​(java.nio.file.Path path)
      Gets the paths to files stored under a prefix.
      default boolean hasFile​(java.lang.String file)
      Checks if the given file is stored in the manifest.
      default boolean hasFile​(java.nio.file.Path file)
      Checks if the given file is stored in the manifest.
      default java.nio.file.Path resolvePath​(java.nio.file.Path path)
      Resolves a path against the base path of the manifest.
      default java.nio.file.Path writeFile​(java.lang.String path, java.io.InputStream fileContentsInputStream)
      Adds a file to the result using the contents of an InputStream.
      default java.nio.file.Path writeFile​(java.lang.String path, java.io.Reader fileContentsReader)
      Adds a file to the result using the contents of a Reader.
      default java.nio.file.Path writeFile​(java.lang.String path, java.lang.Class klass, java.lang.String resource)
      Adds a file to the result using the contents of a resource loaded by calling Class.getResourceAsStream(String).
      default java.nio.file.Path writeFile​(java.lang.String path, java.lang.String fileContentsText)
      Adds a UTF-8 encoded file to the result.
      java.nio.file.Path writeFile​(java.nio.file.Path path, java.io.InputStream fileContentsInputStream)
      Adds a file to the result using the contents of an InputStream.
      java.nio.file.Path writeFile​(java.nio.file.Path path, java.io.Reader fileContentsReader)
      Adds a file to the result using the contents of a Reader.
      default java.nio.file.Path writeFile​(java.nio.file.Path path, java.lang.Class klass, java.lang.String resource)
      Adds a file to the result using the contents of a resource loaded by calling Class.getResourceAsStream(String).
      default java.nio.file.Path writeFile​(java.nio.file.Path path, java.lang.String fileContentsText)
      Adds a UTF-8 encoded file to the result.
      default java.nio.file.Path writeJson​(java.lang.String path, Node node)
      Adds a Node artifact, converting it automatically to JSON.
      default java.nio.file.Path writeJson​(java.nio.file.Path path, Node node)
      Adds a Node artifact, converting it automatically to JSON.
    • Method Detail

      • create

        static FileManifest create​(java.nio.file.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

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

        java.util.Set<java.nio.file.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

        java.nio.file.Path addFile​(java.nio.file.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 java.nio.file.Path resolvePath​(java.nio.file.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

        java.nio.file.Path writeFile​(java.nio.file.Path path,
                                     java.io.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

        java.nio.file.Path writeFile​(java.nio.file.Path path,
                                     java.io.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 java.nio.file.Path writeFile​(java.nio.file.Path path,
                                             java.lang.Class klass,
                                             java.lang.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 java.nio.file.Path writeFile​(java.lang.String path,
                                             java.lang.Class klass,
                                             java.lang.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 java.nio.file.Path writeFile​(java.nio.file.Path path,
                                             java.lang.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 java.nio.file.Path writeFile​(java.lang.String path,
                                             java.lang.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 java.nio.file.Path writeFile​(java.lang.String path,
                                             java.io.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 java.nio.file.Path writeFile​(java.lang.String path,
                                             java.io.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 java.nio.file.Path writeJson​(java.nio.file.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 java.nio.file.Path writeJson​(java.lang.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​(java.nio.file.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​(java.lang.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 java.util.List<java.nio.file.Path> getFilesIn​(java.nio.file.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 java.util.List<java.nio.file.Path> getFilesIn​(java.lang.String path)
        Gets the paths to files stored under a prefix.
        Parameters:
        path - Path prefix.
        Returns:
        Returns the matching file paths.