Package software.amazon.smithy.build
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
Modifier and TypeMethodDescriptiondefault voidaddAllFiles(FileManifest manifest) Adds the files from another FileManifest into this FileManifest.Adds a path to the manifest.static FileManifestCreate a default file manifest for the given base path.Gets the base directory of the manifest.getFiles()Gets all of the files in the result.getFilesIn(String path) Gets the paths to files stored under a prefix.getFilesIn(Path path) Gets the paths to files stored under a prefix.default booleanChecks if the given file is stored in the manifest.default booleanChecks if the given file is stored in the manifest.default PathresolvePath(Path path) Resolves a path against the base path of the manifest.default PathwriteFile(String path, InputStream fileContentsInputStream) Adds a file to the result using the contents of anInputStream.default PathAdds a file to the result using the contents of aReader.default PathAdds a file to the result using the contents of a resource loaded by callingClass.getResourceAsStream(String).default PathAdds a UTF-8 encoded file to the result.writeFile(Path path, InputStream fileContentsInputStream) Adds a file to the result using the contents of anInputStream.Adds a file to the result using the contents of aReader.default PathAdds a file to the result using the contents of a resource loaded by callingClass.getResourceAsStream(String).default PathAdds a UTF-8 encoded file to the result.default PathAdds a Node artifact, converting it automatically to JSON.default PathAdds a Node artifact, converting it automatically to JSON.
-
Method Details
-
create
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
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
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
Adds the files from another FileManifest into this FileManifest.- Parameters:
manifest- Other object to merge with.
-
resolvePath
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
Adds a file to the result using the contents of aReader.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
Adds a file to the result using the contents of anInputStream.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
Adds a file to the result using the contents of a resource loaded by callingClass.getResourceAsStream(String).This method should be preferred when writing class resources to the manifest since it handles closing the created
InputStreamand 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
Adds a file to the result using the contents of a resource loaded by callingClass.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
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
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
Adds a file to the result using the contents of aReader.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
Adds a file to the result using the contents of anInputStream.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
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
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
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
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
Gets the paths to files stored under a prefix.- Parameters:
path- Path prefix.- Returns:
- Returns the matching file paths in sorted order.
-
getFilesIn
Gets the paths to files stored under a prefix.- Parameters:
path- Path prefix.- Returns:
- Returns the matching file paths.
-