use of org.gradle.api.file.DirectoryTree in project gradle by gradle.
the class DefaultSourceDirectorySet method doGetSrcDirTrees.
private Set<DirectoryTree> doGetSrcDirTrees() {
Set<DirectoryTree> result = new LinkedHashSet<DirectoryTree>();
for (Object path : source) {
if (path instanceof SourceDirectorySet) {
SourceDirectorySet nested = (SourceDirectorySet) path;
result.addAll(nested.getSrcDirTrees());
} else {
for (File srcDir : fileResolver.resolveFiles(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;
}
use of org.gradle.api.file.DirectoryTree in project gradle by gradle.
the class SourceFoldersCreator method projectRelativeFolders.
private List<SourceFolder> projectRelativeFolders(Iterable<SourceSet> sourceSets, Function<File, String> provideRelativePath) {
ArrayList<SourceFolder> entries = Lists.newArrayList();
List<SourceSet> sortedSourceSets = sortSourceSetsAsPerUsualConvention(sourceSets);
for (SourceSet sourceSet : sortedSourceSets) {
List<DirectoryTree> sortedSourceDirs = sortSourceDirsAsPerUsualConvention(sourceSet.getAllSource().getSrcDirTrees());
for (DirectoryTree tree : sortedSourceDirs) {
File dir = tree.getDir();
if (dir.isDirectory()) {
String relativePath = provideRelativePath.apply(dir);
SourceFolder folder = new SourceFolder(relativePath, null);
folder.setDir(dir);
folder.setName(dir.getName());
folder.setIncludes(getIncludesForTree(sourceSet, tree));
folder.setExcludes(getExcludesForTree(sourceSet, tree));
entries.add(folder);
}
}
}
return entries;
}
use of org.gradle.api.file.DirectoryTree in project gradle by gradle.
the class FileSystemSubset method contains.
public boolean contains(File file) {
File absoluteFile = file.getAbsoluteFile();
String pathWithSeparator = file.getAbsolutePath() + File.separator;
for (File candidateFile : files) {
String candidateFilePathWithSeparator = candidateFile.getPath() + File.separator;
if (pathWithSeparator.startsWith(candidateFilePathWithSeparator)) {
return true;
}
}
for (DirectoryTree tree : trees) {
if (tree.getDir().getAbsoluteFile().equals(absoluteFile) || DirectoryTrees.contains(FileSystems.getDefault(), tree, absoluteFile)) {
return true;
}
}
return false;
}
Aggregations