api / org.gradle.api.resources

Package org.gradle.api.resources



interface ReadableResource : Resource

A resource that can be read. The simplest example is a file.


interface Resource

A generic resource of some kind. Only describes the resource. There are more specific interface that extend this one and specify ways of accessing the resource's content.


interface ResourceHandler

Provides access to resource-specific utility methods, for example factory methods that create various resources.


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)).


interface TextResourceFactory

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") def sourceFromUri = resources.text.fromUri("https://path/to/the/resource") 
File based factory methods optionally accept a character encoding. If no encoding is specified, the platform's default encoding is used.



open class MissingResourceException : ResourceException

Exception thrown when the resource does not exist


open class ResourceException : GradleException

Generic resource exception that all other resource-related exceptions inherit from.