public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visited = new HashSet<RelativePath>(); WorkResult didWork = delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { visited.add(details.getRelativePath()); action.processFile(details); } }); } }); SyncCopyActionDecoratorFileVisitor fileVisitor = new SyncCopyActionDecoratorFileVisitor(visited, preserveSpec); MinimalFileTree walker = new DirectoryFileTree(baseDestDir).postfix(); walker.visit(fileVisitor); visited.clear(); return new SimpleWorkResult(didWork.getDidWork() || fileVisitor.didWork); }
public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visited = new HashSet<RelativePath>(); WorkResult didWork = delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { visited.add(details.getRelativePath()); action.processFile(details); } }); } }); SyncCopyActionDecoratorFileVisitor fileVisitor = new SyncCopyActionDecoratorFileVisitor(visited); MinimalFileTree walker = new DirectoryFileTree(baseDestDir).postfix(); walker.visit(fileVisitor); visited.clear(); return new SimpleWorkResult(didWork.getDidWork() || fileVisitor.didWork); }
private void processDirectory(File file, final Trie.Builder builder) { new DirectoryFileTree(file).visit(new FileVisitor() { @Override public void visitDir(FileVisitDetails dirDetails) { } @Override public void visitFile(FileVisitDetails fileDetails) { try { ZipEntry zipEntry = new ZipEntry(fileDetails.getPath()); InputStream inputStream = fileDetails.open(); try { processEntry(zipEntry, builder); } finally { inputStream.close(); } } catch (IOException e) { throw new UncheckedIOException(e); } } }); }
@Override public Object addToAntBuilder(final Object node, String nodeName) { final DynamicObject dynamicObject = new BeanDynamicObject(node); for (final DirectoryFileTree tree : trees) { if (!tree.getDir().exists()) { continue; } dynamicObject.invokeMethod(nodeName == null ? "fileset" : nodeName, Collections.singletonMap("dir", AntUtil.maskFilename(tree.getDir().getAbsolutePath())), new Closure<Void>(this) { public Object doCall(Object ignore) { return tree.getPatternSet().addToAntBuilder(node, null); } }); } return null; }
public static void install() { ByteBuddyAgent.install(); ClassLoader targetClassLoader = File.class.getClassLoader(); // interceptor class must be injected to the same classloader as the target class that is intercepted new ByteBuddy().redefine(CountFileSystemOperations.class) .make() .load(targetClassLoader, ClassReloadingStrategy.fromInstalledAgent()); new ByteBuddy().redefine(DirectoryFileTree.class) .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES) .method(ElementMatchers.named("length"), Advice.to(CountFileSystemOperations.LengthMethod.class)) .method(ElementMatchers.named("isFile"), Advice.to(CountFileSystemOperations.IsFileMethod.class)) .method(ElementMatchers.named("isDirectory"), Advice.to(CountFileSystemOperations.IsDirectoryMethod.class)) .method(ElementMatchers.named("lastModified"), Advice.to(CountFileSystemOperations.LastModifiedMethod.class)) .method(ElementMatchers.named("exists"), Advice.to(CountFileSystemOperations.ExistsMethod.class)) ) .make() .load(targetClassLoader, ClassReloadingStrategy.fromInstalledAgent()); }
public static void install() { ByteBuddyAgent.install(); ClassLoader targetClassLoader = DirectoryFileTree.class.getClassLoader(); // interceptor class must be injected to the same classloader as the target class that is intercepted new ByteBuddy().redefine(CountDirectoryScans.class) .make() .load(targetClassLoader, ClassReloadingStrategy.fromInstalledAgent()); new ByteBuddy().redefine(DirectoryFileTree.class) .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES).method(ElementMatchers.named("visitFrom"), Advice.to(CountDirectoryScans.class))) .make() .load(targetClassLoader, ClassReloadingStrategy.fromInstalledAgent()); }
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; }
@Override protected void visitDirectoryTree(DirectoryFileTree directoryTree, List<DefaultFileDetails> fileTreeElements) { // Sort non-root elements as their order is not important List<DefaultFileDetails> subElements = Lists.newArrayList(); super.visitDirectoryTree(directoryTree, subElements); Collections.sort(subElements, FILE_DETAILS_COMPARATOR); fileTreeElements.addAll(subElements); }
@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; }
/** * Returns this collection as a set of {@link DirectoryFileTree} instances. */ protected Collection<DirectoryFileTree> getAsFileTrees() { List<DirectoryFileTree> fileTrees = new ArrayList<DirectoryFileTree>(); for (File file : getFiles()) { if (file.isFile()) { fileTrees.add(new FileBackedDirectoryFileTree(file)); } } return fileTrees; }
@Override public void resolve(FileCollectionResolveContext context) { for (DirectoryTree directoryTree : getSrcDirTrees()) { if (directoryTree.getDir().isDirectory()) { context.add(((DirectoryFileTree) directoryTree).filter(filter)); } } }
@Override public void visitDirectoryTree(DirectoryFileTree directoryTree) { AbstractFileCollectionSnapshotter.this.visitDirectoryTree(directoryTree, fileTreeElements); }
protected void visitDirectoryTree(DirectoryFileTree directoryTree, List<DefaultFileDetails> fileTreeElements) { directoryTree.visit(new FileVisitorImpl(fileTreeElements)); }
public AntFileSetBuilder(Iterable<DirectoryFileTree> trees) { this.trees = trees; }
@Override public void visitContents(FileCollectionResolveContext context) { for (DirectoryTree directoryTree : doGetSrcDirTrees()) { context.add(((DirectoryFileTree) directoryTree).filter(filter)); } }
public AntFileCollectionMatchingTaskBuilder(Iterable<DirectoryFileTree> fileTrees) { this.fileTrees = fileTrees; }
public DirectoryFileTree getMirror() { return new DirectoryFileTree(tmpDir); }
void visitDirectoryTree(DirectoryFileTree directoryTree);