本文整理汇总了Java中org.gradle.api.file.DirectoryTree类的典型用法代码示例。如果您正苦于以下问题:Java DirectoryTree类的具体用法?Java DirectoryTree怎么用?Java DirectoryTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirectoryTree类属于org.gradle.api.file包,在下文中一共展示了DirectoryTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourceRoots
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
List<File> getSourceRoots() {
if (sourceRoots == null) {
sourceRoots = Lists.newArrayList();
for (Object source : sources) {
if (isDirectory(source)) {
sourceRoots.add((File) source);
} else if (isDirectoryTree(source)) {
sourceRoots.add(((DirectoryTree) source).getDir());
} else if (isSourceDirectorySet(source)) {
sourceRoots.addAll(((SourceDirectorySet) source).getSrcDirs());
} else {
throw new UnsupportedOperationException();
}
}
}
return sourceRoots;
}
示例2: projectRelativeFolders
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
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;
}
示例3: contains
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
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;
}
示例4: doGetSrcDirTrees
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
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;
}
示例5: doGetSrcDirTrees
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
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 {
File srcDir = fileResolver.resolve(path);
if (srcDir.exists() && !srcDir.isDirectory()) {
throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir));
}
result.add(new DirectoryFileTree(srcDir, patterns));
}
}
return result;
}
示例6: getIncludesForTree
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
private List<String> getIncludesForTree(SourceSet sourceSet, DirectoryTree directoryTree) {
List<Set<String>> includesByType = getFiltersForTreeGroupedByType(sourceSet, directoryTree, "includes");
for (Set<String> it : includesByType) {
if (it.isEmpty()) {
return Collections.emptyList();
}
}
List<String> allIncludes = CollectionUtils.flattenCollections(String.class, includesByType);
return CollectionUtils.dedup(allIncludes, Equivalence.equals());
}
示例7: getFiltersForTreeGroupedByType
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
private List<Set<String>> getFiltersForTreeGroupedByType(SourceSet sourceSet, DirectoryTree directoryTree, String filterOperation) {
// check for duplicate entries in java and resources
Set<File> javaSrcDirs = sourceSet.getAllJava().getSrcDirs();
Set<File> resSrcDirs = sourceSet.getResources().getSrcDirs();
List<File> srcDirs = CollectionUtils.intersection(Lists.newArrayList(javaSrcDirs, resSrcDirs));
if (!srcDirs.contains(directoryTree.getDir())) {
return Lists.<Set<String>>newArrayList(collectFilters(directoryTree.getPatterns(), filterOperation));
} else {
Set<String> resourcesFilter = collectFilters(sourceSet.getResources().getSrcDirTrees(), directoryTree.getDir(), filterOperation);
Set<String> sourceFilter = collectFilters(sourceSet.getAllJava().getSrcDirTrees(), directoryTree.getDir(), filterOperation);
return Lists.<Set<String>>newArrayList(resourcesFilter, sourceFilter);
}
}
示例8: collectFilters
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
private Set<String> collectFilters(Set<DirectoryTree> directoryTrees, File targetDir, String filterOperation) {
for (DirectoryTree directoryTree : directoryTrees) {
if (directoryTree.getDir().equals(targetDir)) {
PatternSet patterns = directoryTree.getPatterns();
return collectFilters(patterns, filterOperation);
}
}
return Collections.emptySet();
}
示例9: sortSourceDirsAsPerUsualConvention
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
private List<DirectoryTree> sortSourceDirsAsPerUsualConvention(Iterable<DirectoryTree> sourceDirs) {
return CollectionUtils.sort(sourceDirs, new Comparator<DirectoryTree>() {
@Override
public int compare(DirectoryTree left, DirectoryTree right) {
return toComparable(left).compareTo(toComparable(right));
}
});
}
示例10: toComparable
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
private static Comparable toComparable(DirectoryTree tree) {
String path = tree.getDir().getPath();
if (path.endsWith("java")) {
return 0;
} else if (path.endsWith("resources")) {
return 2;
} else {
return 1;
}
}
示例11: of
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
public static ImmutableDirectoryTree of(DirectoryTree source) {
if (source instanceof ImmutableDirectoryTree) {
return (ImmutableDirectoryTree) source;
} else {
return of(source.getDir(), source.getPatterns());
}
}
示例12: getRoots
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
public Iterable<? extends File> getRoots() {
return FileUtils.calculateRoots(
Iterables.concat(files, Iterables.transform(trees, new Function<DirectoryTree, File>() {
@Override
public File apply(DirectoryTree input) {
return input.getDir();
}
}))
);
}
示例13: add
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
public Builder add(DirectoryTree directoryTree) {
lock.lock();
try {
trees.add(ImmutableDirectoryTree.of(directoryTree));
return this;
} finally {
lock.unlock();
}
}
示例14: getSrcDirs
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
public Set<File> getSrcDirs() {
Set<File> dirs = new LinkedHashSet<File>();
for (DirectoryTree tree : getSrcDirTrees()) {
dirs.add(tree.getDir());
}
return dirs;
}
示例15: getSrcDirTrees
import org.gradle.api.file.DirectoryTree; //导入依赖的package包/类
public Set<DirectoryTree> getSrcDirTrees() {
// This implementation is broken. It does not consider include and exclude patterns
Map<File, DirectoryTree> trees = new LinkedHashMap<File, DirectoryTree>();
for (DirectoryTree tree : doGetSrcDirTrees()) {
if (!trees.containsKey(tree.getDir())) {
trees.put(tree.getDir(), tree);
}
}
return new LinkedHashSet<DirectoryTree>(trees.values());
}