| API Documentation: | TextResourceFactory |
|---|
Note: This class is incubating and may change in a future version of Gradle.
Creates TextResources backed by sources such as strings, files, and archive entries.
Example usages:
def sourcedFromString = resources.text.fromString("some text content") def sourcedFromFile = resources.text.fromFile("path/to/file.txt") task someTask {} // assumption: produces a text file and declares it as output def sourcedFromTask = resources.text.fromFile(someTask) def sourcedFromArchiveEntry = resources.text.fromArchiveEntry("path/to/archive.zip", "path/to/archive/entry.txt") configurations { someConfig } // assumption: contains a single archive def sourcedFromConfiguration = resources.text.fromArchiveEntry(configurations.someConfig, "path/to/archive/entry.txt")
File based factory methods optionally accept a character encoding. If no encoding is specified, the platform's default encoding is used.
| Method | Description |
fromArchiveEntry(archive, path) | Incubating Same as |
fromArchiveEntry(archive, entryPath, charset) | Incubating Creates a text resource backed by the archive entry at the given path within the given archive. The archive format is determined based on the archive's file extension. If the archive format is not supported or cannot be determined, any attempt to access the resource will fail with an exception. |
fromFile(file) | Incubating Same as |
fromFile(file, charset) | Incubating Creates a text resource backed by the given file. |
fromString(string) | Incubating Creates a text resource backed by the given string. |
TextResource fromArchiveEntry(Object archive, String path)
Note: This method is incubating and may change in a future version of Gradle.
Same as fromArchiveEntry(archive, path, Charset.defaultCharset().name()).
TextResource fromArchiveEntry(Object archive, String entryPath, String charset)
Note: This method is incubating and may change in a future version of Gradle.
Creates a text resource backed by the archive entry at the given path within the given archive. The archive format is determined based on the archive's file extension. If the archive format is not supported or cannot be determined, any attempt to access the resource will fail with an exception.
TextResource fromFile(Object file)
Note: This method is incubating and may change in a future version of Gradle.
Same as fromFile(file, Charset.defaultCharset()).
TextResource fromFile(Object file, String charset)
Note: This method is incubating and may change in a future version of Gradle.
Creates a text resource backed by the given file.
TextResource fromString(String string)
Note: This method is incubating and may change in a future version of Gradle.
Creates a text resource backed by the given string.