use of org.gradle.api.internal.file.collections.DirectoryFileTree in project gradle by gradle.
the class CompositeFileCollection method getAsFileTrees.
@Override
protected Collection<DirectoryFileTree> getAsFileTrees() {
List<DirectoryFileTree> fileTree = new ArrayList<DirectoryFileTree>();
for (FileCollection source : getSourceCollections()) {
AbstractFileCollection collection = (AbstractFileCollection) source;
fileTree.addAll(collection.getAsFileTrees());
}
return fileTree;
}
use of org.gradle.api.internal.file.collections.DirectoryFileTree in project gradle by gradle.
the class CacheBackedTaskHistoryRepository method getDeclaredOutputFilePaths.
private static ImmutableSet<String> getDeclaredOutputFilePaths(final TaskProperties taskProperties, final StringInterner stringInterner) {
final ImmutableSet.Builder<String> declaredOutputFilePaths = ImmutableSortedSet.naturalOrder();
FileCollectionInternal outputFiles = (FileCollectionInternal) taskProperties.getOutputFiles();
outputFiles.visitRootElements(new FileCollectionVisitor() {
@Override
public void visitCollection(FileCollectionInternal fileCollection) {
addAllPaths(fileCollection, declaredOutputFilePaths, stringInterner);
}
@Override
public void visitTree(FileTreeInternal fileTree) {
DeprecationLogger.nagUserOfDeprecated("Adding file trees which are not directory trees as output files");
addAllPaths(fileTree, declaredOutputFilePaths, stringInterner);
}
@Override
public void visitDirectoryTree(DirectoryFileTree directoryTree) {
addPath(directoryTree.getDir(), declaredOutputFilePaths, stringInterner);
}
});
return declaredOutputFilePaths.build();
}
use of org.gradle.api.internal.file.collections.DirectoryFileTree in project gradle by gradle.
the class CompositeFileCollectionTest method getAsFileTreesReturnsUnionOfFileTrees.
@Test
public void getAsFileTreesReturnsUnionOfFileTrees() {
final DirectoryFileTreeFactory directoryFileTreeFactory = new DefaultDirectoryFileTreeFactory();
final DirectoryFileTree set1 = directoryFileTreeFactory.create(new File("dir1").getAbsoluteFile());
final DirectoryFileTree set2 = directoryFileTreeFactory.create(new File("dir2").getAbsoluteFile());
context.checking(new Expectations() {
{
oneOf(source1).getAsFileTrees();
will(returnValue(toList((Object) set1)));
oneOf(source2).getAsFileTrees();
will(returnValue(toList((Object) set2)));
}
});
assertThat(collection.getAsFileTrees(), equalTo((Collection) toList(set1, set2)));
}
use of org.gradle.api.internal.file.collections.DirectoryFileTree in project gradle by gradle.
the class DefaultSourceDirectorySet method getSourceTrees.
protected Set<DirectoryFileTree> getSourceTrees() {
Set<DirectoryFileTree> result = new LinkedHashSet<>();
for (Object path : source) {
if (path instanceof DefaultSourceDirectorySet) {
DefaultSourceDirectorySet nested = (DefaultSourceDirectorySet) path;
result.addAll(nested.getSourceTrees());
} else {
for (File srcDir : fileCollectionFactory.resolving(path)) {
if (srcDir.exists() && !srcDir.isDirectory()) {
throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir));
}
result.add(directoryFileTreeFactory.create(srcDir, patterns));
}
}
}
return result;
}
Aggregations