Package org.gradle.api.resources
Interface TextResource
-
- All Superinterfaces:
Buildable
public interface TextResource extends 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 inTextResourceFactory(e.g.project.resources.text.fromFile(myFile)).- Since:
- 2.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.FileasFile()Same asasFile(Charset.defaultCharset().name()).java.io.FileasFile(java.lang.String charset)Returns a file containing the resource's text and using the given character encoding.java.io.ReaderasReader()Returns an unbufferedReaderthat allows the resource's text to be read.java.lang.StringasString()Returns a string containing the resource's textTaskDependencygetBuildDependencies()Returns a dependency which contains the tasks which build this artifact.FileCollectiongetInputFiles()Returns the input files registered when this resource is used as task input.java.lang.ObjectgetInputProperties()Returns the input properties registered when this resource is used as task input.
-
-
-
Method Detail
-
asString
java.lang.String asString()
Returns a string containing the resource's text- Returns:
- a string containing the resource's text
-
asReader
java.io.Reader asReader()
Returns an unbufferedReaderthat allows the resource's text to be read. The caller is responsible for closing the reader.- Returns:
- a reader that allows the resource's text to be read.
-
asFile
java.io.File asFile(java.lang.String charset)
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.- Parameters:
charset- a character encoding (e.g."utf-8")- Returns:
- a file containing the resource's text and using the given character encoding
-
asFile
java.io.File asFile()
Same asasFile(Charset.defaultCharset().name()).
-
getInputProperties
@Nullable @Optional @Input java.lang.Object getInputProperties()
Returns the input properties registered when this resource is used as task input. Not typically used directly.- Returns:
- the input properties registered when this resource is used as task input
-
getInputFiles
@Nullable @Optional @PathSensitive(NONE) @InputFiles FileCollection getInputFiles()
Returns the input files registered when this resource is used as task input. Not typically used directly.- Returns:
- the input files registered when this resource is used as task input
-
getBuildDependencies
@Internal TaskDependency getBuildDependencies()
Description copied from interface:BuildableReturns a dependency which contains the tasks which build this artifact. AllBuildableimplementations must ensure that the returned dependency object is live, so that it tracks changes to the dependencies of this buildable.- Specified by:
getBuildDependenciesin interfaceBuildable- Returns:
- The dependency. Never returns null. Returns an empty dependency when this artifact is not built by any tasks.
-
-