api / org.gradle.api.file

Package org.gradle.api.file

Types

ConfigurableFileCollection

interface ConfigurableFileCollection : FileCollection

A ConfigurableFileCollection is a mutable FileCollection.

You can obtain an instance of ConfigurableFileCollection by calling

ConfigurableFileTree

interface ConfigurableFileTree : FileTree, DirectoryTree, PatternFilterable, Buildable

A FileTree with a single base directory, which can be configured and modified.

You can obtain a ConfigurableFileTree instance by calling org.gradle.api.Project#fileTree(java.util.Map).

ContentFilterable

interface ContentFilterable

Represents some binary resource whose content can be filtered.

CopyProcessingSpec

interface CopyProcessingSpec : ContentFilterable

Specifies the destination of a copy.

CopySourceSpec

interface CopySourceSpec

Specifies sources for a file copy.

CopySpec

interface CopySpec : CopySourceSpec, CopyProcessingSpec, PatternFilterable

A set of specifications for copying files. This includes:

  • source directories (multiples allowed)
  • destination directory
  • ANT like include patterns
  • ANT like exclude patterns
  • File relocating rules
  • renaming rules
  • content filters
CopySpecs may be nested by passing a closure to one of the from methods. The closure creates a child CopySpec and delegates methods in the closure to the child. Child CopySpecs inherit any values specified in the parent. This allows constructs like:
 def myCopySpec = project.copySpec { into('webroot') exclude('**/.data/**') from('src/main/webapp') { include '**/*.jsp' } from('src/main/js') { include '**/*.js' } } 
In this example, the into and exclude specifications at the root level are inherited by the two child CopySpecs. Copy specs can be reused in other copy specs via #with(CopySpec...) method. This enables reuse of the copy spec instances.
 def contentSpec = copySpec { from("content") { include "**/*.txt" } } task copy(type: Copy) { into "$buildDir/copy" with contentSpec } 

DeleteSpec

interface DeleteSpec

A specification for deleting files from the filesystem.

Directory

interface Directory : FileSystemLocation

Represents a directory at some fixed location on the file system.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created using the #dir(String) method or using various methods on ProjectLayout such as ProjectLayout#getProjectDirectory().

DirectoryProperty

interface DirectoryProperty : Provider<Directory>, Property<Directory>

Represents some configurable directory location, whose value is mutable and is not necessarily currently known until later.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created using the ProjectLayout#directoryProperty() method.

DirectoryTree

interface DirectoryTree

A directory with some associated include and exclude patterns.

This interface does not allow mutation. However, the actual implementation may not be immutable.

DirectoryVar

interface DirectoryVar : DirectoryProperty, PropertyState<Directory>

Represents some configurable directory location, whose value is mutable and is not necessarily currently known until later.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created using the ProjectLayout#newDirectoryVar() method.

DuplicatesStrategy

class DuplicatesStrategy

Strategies for dealing with the potential creation of duplicate files for or archive entries.

EmptyFileVisitor

open class EmptyFileVisitor : FileVisitor

The EmptyFileVisitor can be extends by implementations that only require to implement one of the 2 visit methods (dir or file). This is just to limit the amount of code clutter when not both visit methods need to be implemented.

FileCollection

interface FileCollection : MutableIterable<File>, AntBuilderAware, Buildable

A FileCollection represents a collection of files which you can query in certain ways. A file collection is often used to define a classpath, or to add files to a container.

You can obtain a FileCollection instance using org.gradle.api.Project#files.

FileCopyDetails

interface FileCopyDetails : FileTreeElement, ContentFilterable

Provides details about a file or directory about to be copied, and allows some aspects of the destination file to be modified.

Using this interface, you can change the destination path of the file, filter the content of the file, or exclude the file from the result entirely.

Access to the source file itself after any filters have been added is not a supported operation.

FileSystemLocation

interface FileSystemLocation

Represents some immutable location on the file system.

Note: This interface is not intended for implementation by build script or plugin authors.

FileTree

interface FileTree : FileCollection

A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive.

You can obtain a FileTree instance using org.gradle.api.Project#fileTree(java.util.Map), org.gradle.api.Project#zipTree(Object) or org.gradle.api.Project#tarTree(Object).

FileTreeElement

interface FileTreeElement

Information about a file in a FileTree.

FileVisitDetails

interface FileVisitDetails : FileTreeElement

Provides access to details about a file or directory being visited by a FileVisitor.

FileVisitor

interface FileVisitor

A FileVisitor is used to visit each of the files in a FileTree.

ProjectLayout

interface ProjectLayout

Provides access to several important locations for a project. An instance of the factory can be injected into a task or plugin by annotating a public constructor or method with javax.inject.Inject. It is also available via org.gradle.api.Project#getLayout().

RegularFile

interface RegularFile : FileSystemLocation

Represents a regular file at a fixed location on the file system. A regular file is a file that is not a directory and is not some special kind of file such as a device.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created from a Directory instance using the Directory#file(String) method or via various methods on ProjectLayout such as ProjectLayout#getProjectDirectory().

RegularFileProperty

interface RegularFileProperty : Provider<RegularFile>, Property<RegularFile>

Represents some configurable regular file location, whose value is mutable and not necessarily currently known until later.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created using the ProjectLayout#fileProperty() method.

RegularFileVar

interface RegularFileVar : RegularFileProperty, PropertyState<RegularFile>

Represents some configurable regular file location, whose value is mutable and not necessarily currently known until later.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created using the ProjectLayout#newFileVar() method.

RelativePath

open class RelativePath : Serializable, Comparable<RelativePath>, CharSequence

Represents a relative path from some base directory to a file. Used in file copying to represent both a source and target file path when copying files.

RelativePath instances are immutable.

ReproducibleFileVisitor

interface ReproducibleFileVisitor : FileVisitor

Visitor which can request a reproducible file order.

SourceDirectorySet

interface SourceDirectorySet : FileTree, PatternFilterable, Named, Describable

A SourceDirectorySet represents a set of source files composed from a set of source directories, along with associated include and exclude patterns.

SourceDirectorySet extends FileTree. The contents of the file tree represent the source files of this set, arranged in a hierarchy. The file tree is live and reflects changes to the source directories and their contents.

Exceptions

DuplicateFileCopyingException

open class DuplicateFileCopyingException : GradleException

Thrown when more than one file with the same relative path name is to be copied and the DuplicatesStrategy is set to DuplicatesStrategy.FAIL

UnableToDeleteFileException

open class UnableToDeleteFileException : UncheckedIOException

Thrown by Gradle when it is unable to delete a file.