Interface FileTree
-
- All Superinterfaces:
AntBuilderAware,Buildable,FileCollection,java.lang.Iterable<java.io.File>
- All Known Subinterfaces:
AntlrSourceDirectorySet,ConfigurableFileTree,GroovySourceDirectorySet,ScalaSourceDirectorySet,SourceDirectorySet
public interface FileTree extends FileCollection
A
FileTreerepresents a hierarchy of files. It extendsFileCollectionto add hierarchy query and manipulation methods. You typically use aFileTreeto represent files to copy or the contents of an archive.You can obtain a
FileTreeinstance usingProject.fileTree(java.util.Map),Project.zipTree(Object)orProject.tarTree(Object).The order of the files in a
FileTreeis not stable, even on a single computer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.file.FileCollection
FileCollection.AntType
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FileTreegetAsFileTree()Returns this.java.util.Set<java.io.File>getFiles()Returns the contents of this tree as a flattened Set.FileTreematching(Closure filterConfigClosure)Restricts the contents of this tree to those files matching the given filter.FileTreematching(Action<? super PatternFilterable> filterConfigAction)Restricts the contents of this tree to those files matching the given filter.FileTreematching(PatternFilterable patterns)Restricts the contents of this tree to those files matching the given filter.FileTreeplus(FileTree fileTree)Returns aFileTreewhich contains the union of this tree and the given tree.FileTreevisit(Closure visitor)Visits the files and directories in this file tree.FileTreevisit(Action<? super FileVisitDetails> visitor)Visits the files and directories in this file tree.FileTreevisit(FileVisitor visitor)Visits the files and directories in this file tree.-
Methods inherited from interface org.gradle.api.Buildable
getBuildDependencies
-
Methods inherited from interface org.gradle.api.file.FileCollection
addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsPath, getElements, getSingleFile, isEmpty, minus, plus
-
-
-
-
Method Detail
-
matching
FileTree matching(@DelegatesTo(PatternFilterable.class) Closure filterConfigClosure)
Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.
The given closure is used to configure the filter. A
PatternFilterableis passed to the closure as its delegate. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.- Parameters:
filterConfigClosure- the closure to use to configure the filter.- Returns:
- The filtered tree.
-
matching
FileTree matching(Action<? super PatternFilterable> filterConfigAction)
Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.
The given action is used to configure the filter. A
PatternFilterableis passed to the action. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.- Parameters:
filterConfigAction- Action to use to configure the filter.- Returns:
- The filtered tree.
- Since:
- 3.3
-
matching
FileTree matching(PatternFilterable patterns)
Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.
The given pattern set is used to configure the filter. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.
- Parameters:
patterns- the pattern set to use to configure the filter.- Returns:
- The filtered tree.
-
visit
FileTree visit(FileVisitor visitor)
Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children.- Parameters:
visitor- The visitor.- Returns:
- this
-
visit
FileTree visit(@DelegatesTo(FileVisitDetails.class) Closure visitor)
Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children. The file/directory to be visited is passed to the given closure as aFileVisitDetails- Parameters:
visitor- The visitor.- Returns:
- this
-
visit
FileTree visit(Action<? super FileVisitDetails> visitor)
Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children. The file/directory to be visited is passed to the given action as aFileVisitDetails- Parameters:
visitor- The visitor.- Returns:
- this
-
plus
FileTree plus(FileTree fileTree)
Returns aFileTreewhich contains the union of this tree and the given tree. The returned tree is live, so that changes to either this tree or the other source tree are reflected in the returned tree.- Parameters:
fileTree- The tree. Should not be null.- Returns:
- The union of this tree and the given tree.
-
getAsFileTree
FileTree getAsFileTree()
Returns this.- Specified by:
getAsFileTreein interfaceFileCollection- Returns:
- this
-
getFiles
java.util.Set<java.io.File> getFiles()
Returns the contents of this tree as a flattened Set.The order of the files in a
FileTreeis not stable, even on a single computer.- Specified by:
getFilesin interfaceFileCollection- Returns:
- The files. Returns an empty set if this tree is empty.
-
-