api / org.gradle.api.resources / TextResource

TextResource

@Incubating interface TextResource : Buildable

A read-only body of text backed by a string, file, archive entry, or other source. To create a text resource, use one of the factory methods in TextResourceFactory (e.g. project.resources.text.fromFile(myFile)).

Since
2.2

Functions

asFile

abstract fun asFile(charset: String): File

Returns a file containing the resource's text and using the given character encoding. If this resource is backed by a file with a matching encoding, that file may be returned. Otherwise, a temporary file will be created and returned.

abstract fun asFile(): File

Same as asFile(Charset.defaultCharset().name()).

asReader

abstract fun asReader(): Reader

Returns an unbuffered Reader that allows the resource's text to be read. The caller is responsible for closing the reader.

asString

abstract fun asString(): String

Returns a string containing the resource's text

getBuildDependencies

abstract fun getBuildDependencies(): TaskDependency

getInputFiles

abstract fun getInputFiles(): FileCollection

Returns the input files registered when this resource is used as task input. Not typically used directly.

getInputProperties

abstract fun getInputProperties(): Any

Returns the input properties registered when this resource is used as task input. Not typically used directly.