public interface TextResourceFactory
TextResource
s 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") def sourceFromUri = resources.text.fromUri("https://example.com/resource") def sourceFromInsecureUri = resources.text.fromInsecureUri("http://example.com/resource")File based factory methods optionally accept a character encoding. If no encoding is specified, the platform's default encoding is used.
Modifier and Type | Method | Description |
---|---|---|
TextResource |
fromArchiveEntry(java.lang.Object archive,
java.lang.String path) |
Same as
fromArchiveEntry(archive, path, Charset.defaultCharset().name()) . |
TextResource |
fromArchiveEntry(java.lang.Object archive,
java.lang.String entryPath,
java.lang.String charset) |
Creates a text resource backed by the archive entry at the given path within the given archive.
|
TextResource |
fromFile(java.lang.Object file) |
Same as
fromFile(file, Charset.defaultCharset()) . |
TextResource |
fromFile(java.lang.Object file,
java.lang.String charset) |
Creates a text resource backed by the given file.
|
TextResource |
fromInsecureUri(java.lang.Object uri) |
Creates a text resource backed by the given uri.
|
TextResource |
fromString(java.lang.String string) |
Creates a text resource backed by the given string.
|
TextResource |
fromUri(java.lang.Object uri) |
Creates a text resource backed by the given uri.
|
TextResource fromString(java.lang.String string)
string
- a stringTextResource fromFile(java.lang.Object file, java.lang.String charset)
file
- a text file evaluated as per Project.files(Object...)
charset
- the file's character encoding (e.g. "utf-8"
)TextResource fromFile(java.lang.Object file)
fromFile(file, Charset.defaultCharset())
.fromFile(Object, String)
TextResource fromArchiveEntry(java.lang.Object archive, java.lang.String entryPath, java.lang.String charset)
archive
- an archive file evaluated as per Project.files(Object...)
entryPath
- the path to an archive entrycharset
- the archive entry's character encoding (e.g. "utf-8"
)TextResource fromArchiveEntry(java.lang.Object archive, java.lang.String path)
fromArchiveEntry(archive, path, Charset.defaultCharset().name())
.TextResource fromUri(java.lang.Object uri)
uri
- a URI as evaluated by Project.uri(Object)
TextResource fromInsecureUri(java.lang.Object uri)
uri
- a URI as evaluated by Project.uri(Object)
fromUri(Object)