@Override public File apply(DirectoryTree input) { return input.getDir(); } }))
public static ImmutableDirectoryTree of(DirectoryTree source) { if (source instanceof ImmutableDirectoryTree) { return (ImmutableDirectoryTree) source; } else { return of(source.getDir(), source.getPatterns()); } }
public Set<File> getSrcDirs() { Set<File> dirs = new LinkedHashSet<File>(); for (DirectoryTree tree : getSrcDirTrees()) { dirs.add(tree.getDir()); } return dirs; }
public static boolean contains(FileSystem fileSystem, DirectoryTree tree, File file) { String prefix = tree.getDir().getAbsolutePath() + File.separator; if (!file.getAbsolutePath().startsWith(prefix)) { return false; } RelativePath path = RelativePath.parse(true, file.getAbsolutePath().substring(prefix.length())); return tree.getPatterns().getAsSpec().isSatisfiedBy(new DefaultFileTreeElement(file, path, fileSystem, fileSystem)); }
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()); }
Path dir = dirTree.getDir().toPath(); if (!path.startsWith(dir)) { return false; final RelativePath relativePath = new RelativePath(true, segments); return dirTree.getPatterns().getAsSpec().isSatisfiedBy(new FileTreeElement() { public void copyTo(OutputStream arg0) { throw new UnsupportedOperationException(); } public boolean copyTo(File arg0) { throw new UnsupportedOperationException(); }
public Set<File> getSrcDirs() { Set<File> dirs = new LinkedHashSet<File>(); for (DirectoryTree tree : getSrcDirTrees()) { dirs.add(tree.getDir()); } return dirs; }
void register(Watcher watcher) throws IOException { for (FileCollection files : fileCollections) { if (files instanceof DirectoryTree) { DirectoryTree dirTree = (DirectoryTree) files; watcher.register(dirTree.getDir().toPath()); } else { for (File file : files) { watcher.register(file.toPath()); } } } }
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; }
@TaskAction public void run() throws IOException { final PatternSet patternSet = new PatternSet(); patternSet.setIncludes(this.input.getIncludes()); patternSet.setExcludes(this.input.getExcludes()); for (final DirectoryTree dirTree : this.input.getSrcDirTrees()) { final File dir = dirTree.getDir(); if (!dir.exists() || !dir.isDirectory()) { continue; } final FileTree tree = this.getProject().fileTree(dir).matching(this.input.getFilter()).matching(patternSet); for (final File file : tree) { final Map<Integer, String> matches = this.getFileMatches(Files.toString(file, Charsets.UTF_8)); if (!matches.isEmpty()) { System.out.println(); LOGGER.warn("{} TODO{} found in `{}`", matches.size(), matches.size() == 1 ? "" : "s", file.getName()); for (final Map.Entry<Integer, String> match : matches.entrySet()) { LOGGER.warn("L{}: {}", match.getKey(), match.getValue().trim()); } } } } }
private String tryFindSourceSetPath(final String sourceSetName) { try { if (getProject().getPlugins().findPlugin(JavaPlugin.class) != null) { final SourceSetContainer sourceSets = (SourceSetContainer) getProject().getProperties() .get(SOURCE_SETS_PROPERTY); if (sourceSets != null) { return sourceSets.getByName(sourceSetName).getJava().getSrcDirTrees().iterator().next().getDir() .getAbsolutePath(); } } } finally { } return null; }
File dir = dirTree.getDir();
File dir = dirTree.getDir(); getLogger().debug("PARSING DIR >> " + dir);