use of org.gradle.api.internal.file.collections.FileBackedDirectoryFileTree in project gradle by gradle.
the class AbstractFileCollection method getAsFileTrees.
/**
* Returns this collection as a set of {@link DirectoryFileTree} instance. These are used to map to Ant types.
*/
protected Collection<DirectoryTree> getAsFileTrees() {
List<DirectoryTree> fileTrees = new ArrayList<>();
visitStructure(new FileCollectionStructureVisitor() {
@Override
public void visitCollection(Source source, Iterable<File> contents) {
for (File file : contents) {
if (file.isFile()) {
fileTrees.add(new FileBackedDirectoryFileTree(file));
}
}
}
@Override
public void visitFileTree(File root, PatternSet patterns, FileTreeInternal fileTree) {
if (root.isFile()) {
fileTrees.add(new FileBackedDirectoryFileTree(root));
} else if (root.isDirectory()) {
fileTrees.add(new DirectoryTree() {
@Override
public File getDir() {
return root;
}
@Override
public PatternSet getPatterns() {
return patterns;
}
});
}
}
@Override
public void visitGenericFileTree(FileTreeInternal fileTree, FileSystemMirroringFileTree sourceTree) {
// Visit the contents of the tree to generate the tree
if (visitAll(sourceTree)) {
fileTrees.add(sourceTree.getMirror());
}
}
@Override
public void visitFileTreeBackedByFile(File file, FileTreeInternal fileTree, FileSystemMirroringFileTree sourceTree) {
visitGenericFileTree(fileTree, sourceTree);
}
});
return fileTrees;
}
Aggregations