Java 类org.gradle.api.file.FileVisitDetails 实例源码

项目:gradle-wsimport-plugin    文件:WsimportTask.java   
/**
 * Run wsimport
 */
@TaskAction
protected void wsimport() {
    Objects.requireNonNull(getWsdls()).visit(new EmptyFileVisitor() {
        /**
         * @see org.gradle.api.file.EmptyFileVisitor#visitFile(org.gradle.api.file.FileVisitDetails)
         */
        @Override
        public void visitFile(FileVisitDetails file) {
            Path relativeWsdlFile = Paths.get(file.getPath());
            Path absoluteWsdlFile = file.getFile().toPath();

            if (relativeWsdlFile.isAbsolute() || !absoluteWsdlFile.isAbsolute()) {
                throw new IllegalArgumentException(String.format("Illegal file visit details %s", file));
            }

            Path baseDir = Objects.requireNonNull(absoluteWsdlFile.getRoot()).resolve(
                    absoluteWsdlFile.subpath(0, absoluteWsdlFile.getNameCount() - relativeWsdlFile.getNameCount()));

            runWsimport(baseDir, relativeWsdlFile);
        }
    });
}
项目:Reer    文件:PackageListGenerator.java   
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);
            }
        }
    });
}
项目:Reer    文件:DefaultJarSnapshotter.java   
JarSnapshot createSnapshot(HashCode hash, FileTree classes, final ClassFilesAnalyzer analyzer) {
    final Map<String, HashCode> hashes = Maps.newHashMap();
    classes.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            analyzer.visitFile(fileDetails);
            String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
            HashCode classHash = hasher.hash(fileDetails.getFile());
            hashes.put(className, classHash);
        }
    });

    return new JarSnapshot(new JarSnapshotData(hash, hashes, analyzer.getAnalysis()));
}
项目:Reer    文件:IncrementalNativeCompiler.java   
protected void handleDiscoveredInputs(T spec, IncrementalCompilation compilation, final DiscoveredInputRecorder discoveredInputRecorder) {
    for (File includeFile : compilation.getDiscoveredInputs()) {
        discoveredInputRecorder.newInput(includeFile);
    }

    if (sourceFilesUseMacroIncludes(spec.getSourceFiles(), compilation.getFinalState())) {
        LOGGER.info("After parsing the source files, Gradle cannot calculate the exact set of include files for {}. Every file in the include search path will be considered an input.", task.getName());
        for (final File includeRoot : spec.getIncludeRoots()) {
            LOGGER.info("adding files in {} to discovered inputs for {}", includeRoot, task.getName());
            directoryFileTreeFactory.create(includeRoot).visit(new EmptyFileVisitor() {
                @Override
                public void visitFile(FileVisitDetails fileDetails) {
                    discoveredInputRecorder.newInput(fileDetails.getFile());
                }
            });
        }
    }
}
项目:Reer    文件:TarFileTree.java   
@Override
public void visitTreeOrBackingFile(final FileVisitor visitor) {
    File backingFile = getBackingFile();
    if (backingFile!=null) {
        new SingletonFileTree(backingFile).visit(visitor);
    } else {
        // We need to wrap the visitor so that the file seen by the visitor has already
        // been extracted from the archive and we do not try to extract it again.
        // It's unsafe to keep the FileVisitDetails provided by TarFileTree directly
        // because we do not expect to visit the same paths again (after extracting everything).
        visit(new FileVisitor() {
            @Override
            public void visitDir(FileVisitDetails dirDetails) {
                visitor.visitDir(new DefaultFileVisitDetails(dirDetails.getFile(), chmod, stat));
            }

            @Override
            public void visitFile(FileVisitDetails fileDetails) {
                visitor.visitFile(new DefaultFileVisitDetails(fileDetails.getFile(), chmod, stat));
            }
        });
    }
}
项目:Reer    文件:PathKeyFileStore.java   
public Set<? extends LocallyAvailableResource> search(String pattern) {
    if (!getBaseDir().exists()) {
        return Collections.emptySet();
    }

    final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
    findFiles(pattern).visit(new EmptyFileVisitor() {
        public void visitFile(FileVisitDetails fileDetails) {
            final File file = fileDetails.getFile();
            // We cannot clean in progress markers, or in progress files here because
            // the file system visitor stuff can't handle the file system mutating while visiting
            if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
                entries.add(entryAt(file));
            }
        }
    });

    return entries;
}
项目:Reer    文件:JavaScriptMinify.java   
@Override
public void visitFile(final FileVisitDetails fileDetails) {
    final File outputFileDir = new File(destinationDir, fileDetails.getRelativePath().getParent().getPathString());

    // Copy the raw form
    FileOperations fileOperations = (ProjectInternal) getProject();
    fileOperations.copy(new Action<CopySpec>() {
        @Override
        public void execute(CopySpec copySpec) {
            copySpec.from(fileDetails.getFile()).into(outputFileDir);
        }
    });

    // Capture the relative file
    relativeFiles.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
}
项目:Pushjet-Android    文件:DefaultJarSnapshotter.java   
JarSnapshot createSnapshot(byte[] hash, FileTree classes, final ClassFilesAnalyzer analyzer) {
    final Map<String, byte[]> hashes = new HashMap<String, byte[]>();
    classes.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            analyzer.visitFile(fileDetails);
            String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
            byte[] classHash = hasher.hash(fileDetails.getFile());
            hashes.put(className, classHash);
        }
    });

    return new JarSnapshot(new JarSnapshotData(hash, hashes, analyzer.getAnalysis()));
}
项目:Pushjet-Android    文件:PathKeyFileStore.java   
public Set<? extends LocallyAvailableResource> search(String pattern) {
    if (!getBaseDir().exists()) {
        return Collections.emptySet();
    }

    final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
    findFiles(pattern).visit(new EmptyFileVisitor() {
        public void visitFile(FileVisitDetails fileDetails) {
            final File file = fileDetails.getFile();
            // We cannot clean in progress markers, or in progress files here because
            // the file system visitor stuff can't handle the file system mutating while visiting
            if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
                entries.add(entryAt(file));
            }
        }
    });

    return entries;
}
项目:Pushjet-Android    文件:PathKeyFileStore.java   
public Set<? extends LocallyAvailableResource> search(String pattern) {
    if (!getBaseDir().exists()) {
        return Collections.emptySet();
    }

    final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
    findFiles(pattern).visit(new EmptyFileVisitor() {
        public void visitFile(FileVisitDetails fileDetails) {
            final File file = fileDetails.getFile();
            // We cannot clean in progress markers, or in progress files here because
            // the file system visitor stuff can't handle the file system mutating while visiting
            if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
                entries.add(entryAt(file));
            }
        }
    });

    return entries;
}
项目:st-js-gradle-plugin    文件:GenerateStJsTask.java   
private Collection<String> accumulatePackages() {
    final Collection<String> result = new HashSet<>();

    compileSourceRoots.getAsFileTree().visit(new FileVisitor() {

        @Override
        public void visitDir(FileVisitDetails dirDetails) {
            final String packageName =
                    dirDetails.getRelativePath().getPathString().replace(File.separatorChar, '.');
            if (logger.isDebugEnabled()) {
                logger.debug("Packages: " + packageName);
            }
            result.add(packageName);
        }

        @Override
        public void visitFile(FileVisitDetails fileDetails) {
            // ignore
        }
    });
    return result;
}
项目:javaccPlugin    文件:NonJavaccSourceFileVisitorTest.java   
@Test
public void givenATextInputFileInSubDirectoryWhenVisitFileThenFileIsCopiedToTaskOutputDirectory() {
    inputDirectory = new File(getClass().getResource("/javacc/inputWithNonJavaccFilesInSubDirectory").getFile());
    when(compiler.getInputDirectory()).thenReturn(inputDirectory);

    FileVisitDetails fileDetails = mock(FileVisitDetails.class);
    when(fileDetails.getFile()).thenReturn(new File(inputDirectory, TEXT_INPUT_IN_SUBFOLDER_FILENAME));
    when(fileDetails.getName()).thenReturn(TEXT_INPUT_IN_SUBFOLDER_FILENAME);

    sourceVisitor.visitFile(fileDetails);

    assertEquals(1, outputDirectory.list().length);
    assertTrue(Arrays.asList(outputDirectory.list()).contains("sub"));

    final File outputSubDirectory = new File(outputDirectory, "sub");
    assertEquals(1, outputSubDirectory.list().length);
    assertTrue(Arrays.asList(outputSubDirectory.list()).contains(TEXT_INPUT_FILENAME));
}
项目:Reer    文件:SerializableCoffeeScriptCompileSpec.java   
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
项目:Reer    文件:ClassFilesAnalyzer.java   
@Override
public void visitFile(FileVisitDetails fileDetails) {
    File file = fileDetails.getFile();
    if (!hasExtension(file, ".class")) {
        return;
    }
    String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
    if (!className.startsWith(packagePrefix)) {
        return;
    }

    ClassAnalysis analysis = analyzer.getClassAnalysis(className, file);
    accumulator.addClass(className, analysis.isDependencyToAll(), analysis.getClassDependencies());
}
项目:Reer    文件:DefaultTestClassScanner.java   
private void detectionScan() {
    testFrameworkDetector.startDetection(testClassProcessor);
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            testFrameworkDetector.processTestClass(fileDetails.getFile());
        }
    });
}
项目:Reer    文件:DefaultTestClassScanner.java   
private void filenameScan() {
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            String className = fileDetails.getRelativePath().getPathString().replaceAll("\\.class", "").replace('/', '.');
            TestClassRunInfo testClass = new DefaultTestClassRunInfo(className);
            testClassProcessor.processTestClass(testClass);
        }
    });
}
项目:Reer    文件:DefaultTestClassScanner.java   
@Override
public void visitFile(FileVisitDetails fileDetails) {
    final File file = fileDetails.getFile();

    if (file.getAbsolutePath().endsWith(".class")) {
        visitClassFile(fileDetails);
    }
}
项目:Reer    文件:TarTaskOutputPacker.java   
private void storeDirectoryEntry(FileVisitDetails dirDetails, String propertyRoot, TarOutputStream outputStream) throws IOException {
    String path = dirDetails.getRelativePath().getPathString();
    TarEntry entry = new TarEntry(propertyRoot + path + "/");
    storeModificationTime(entry, dirDetails.getLastModified());
    entry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
    outputStream.putNextEntry(entry);
    outputStream.closeEntry();
}
项目:Reer    文件:CompositeFileTree.java   
@Override
public FileTree visit(Action<? super FileVisitDetails> visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
项目:Reer    文件:DefaultDirectoryWalker.java   
@Override
public void walkDir(File file, RelativePath path, FileVisitor visitor, Spec<? super FileTreeElement> spec, AtomicBoolean stopFlag, boolean postfix) {
    File[] children = file.listFiles();
    if (children == null) {
        if (file.isDirectory() && !file.canRead()) {
            throw new GradleException(String.format("Could not list contents of directory '%s' as it is not readable.", file));
        }
        // else, might be a link which points to nothing, or has been removed while we're visiting, or ...
        throw new GradleException(String.format("Could not list contents of '%s'.", file));
    }
    List<FileVisitDetails> dirs = new ArrayList<FileVisitDetails>();
    for (int i = 0; !stopFlag.get() && i < children.length; i++) {
        File child = children[i];
        boolean isFile = child.isFile();
        RelativePath childPath = path.append(isFile, child.getName());
        FileVisitDetails details = new DefaultFileVisitDetails(child, childPath, stopFlag, fileSystem, fileSystem, !isFile);
        if (DirectoryFileTree.isAllowed(details, spec)) {
            if (isFile) {
                visitor.visitFile(details);
            } else {
                dirs.add(details);
            }
        }
    }

    // now handle dirs
    for (int i = 0; !stopFlag.get() && i < dirs.size(); i++) {
        FileVisitDetails dir = dirs.get(i);
        if (postfix) {
            walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
            visitor.visitDir(dir);
        } else {
            visitor.visitDir(dir);
            walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
        }
    }
}
项目:Reer    文件:DirectoryFileTree.java   
private void processSingleFile(File file, FileVisitor visitor, Spec<FileTreeElement> spec, AtomicBoolean stopFlag) {
    RelativePath path = new RelativePath(true, file.getName());
    FileVisitDetails details = new DefaultFileVisitDetails(file, path, stopFlag, fileSystem, fileSystem, false);
    if (isAllowed(details, spec)) {
        visitor.visitFile(details);
    }
}
项目:Reer    文件:DefaultFileCopyDetails.java   
public DefaultFileCopyDetails(FileVisitDetails fileDetails, CopySpecResolver specResolver, Chmod chmod) {
    super(chmod);
    this.filterChain = new FilterChain(specResolver.getFilteringCharset());
    this.fileDetails = fileDetails;
    this.specResolver = specResolver;
    this.duplicatesStrategy = specResolver.getDuplicatesStrategy();
}
项目:Reer    文件:CopyFileVisitorImpl.java   
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : copySpecResolver.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
项目:Reer    文件:SyncCopyActionDecorator.java   
private void maybeDelete(FileVisitDetails fileDetails, boolean isDir) {
    RelativePath path = fileDetails.getRelativePath();
    if (!visited.contains(path)) {
        if (preserveSet.isEmpty() || !preserveSpec.isSatisfiedBy(fileDetails)) {
            if (isDir) {
                GFileUtils.deleteDirectory(fileDetails.getFile());
            } else {
                GFileUtils.deleteQuietly(fileDetails.getFile());
            }
            didWork = true;
        }
    }
}
项目:ide-plugins    文件:EclipsePluginTestClassScanner.java   
@Override
public void run() {
    this.candidateClassFiles.visit(new ClassFileVisitor() {

        @Override
        public void visitClassFile(FileVisitDetails fileDetails) {
            String className = fileDetails.getRelativePath().getPathString().replaceAll("\\.class", "").replace('/', '.');
            TestClassRunInfo testClass = new DefaultTestClassRunInfo(className);
            EclipsePluginTestClassScanner.this.testClassProcessor.processTestClass(testClass);
        }
    });
}
项目:ide-plugins    文件:EclipsePluginTestClassScanner.java   
@Override
public void visitFile(FileVisitDetails fileDetails) {
    final File file = fileDetails.getFile();
    if (isValidTestClassFile(file)) {
        visitClassFile(fileDetails);
    }
}
项目:Pushjet-Android    文件:SerializableCoffeeScriptCompileSpec.java   
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
项目:Pushjet-Android    文件:ClassFilesAnalyzer.java   
public void visitFile(FileVisitDetails fileDetails) {
    File file = fileDetails.getFile();
    if (!file.getName().endsWith(".class")) {
        return;
    }
    String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
    if (!className.startsWith(packagePrefix)) {
        return;
    }

    ClassAnalysis analysis = analyzer.getClassAnalysis(className, file);
    accumulator.addClass(className, analysis.isDependencyToAll(), analysis.getClassDependencies());
}
项目:Pushjet-Android    文件:CopyFileVisitorImpl.java   
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : copySpecResolver.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
项目:Pushjet-Android    文件:SyncCopyActionDecorator.java   
private void maybeDelete(FileVisitDetails fileDetails, boolean isDir) {
    RelativePath path = fileDetails.getRelativePath();
    if (!visited.contains(path)) {
        if (isDir) {
            GFileUtils.deleteDirectory(fileDetails.getFile());
        } else {
            GFileUtils.deleteQuietly(fileDetails.getFile());
        }
        didWork = true;
    }
}
项目:Pushjet-Android    文件:DefaultTestClassScanner.java   
private void detectionScan() {
    testFrameworkDetector.startDetection(testClassProcessor);
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            testFrameworkDetector.processTestClass(fileDetails.getFile());
        }
    });
}
项目:Pushjet-Android    文件:DefaultTestClassScanner.java   
private void filenameScan() {
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            String className = fileDetails.getRelativePath().getPathString().replaceAll("\\.class", "").replace('/', '.');
            TestClassRunInfo testClass = new DefaultTestClassRunInfo(className);
            testClassProcessor.processTestClass(testClass);
        }
    });
}
项目:Pushjet-Android    文件:DefaultTestClassScanner.java   
public void visitFile(FileVisitDetails fileDetails) {
    final File file = fileDetails.getFile();

    if (file.getAbsolutePath().endsWith(".class")) {
        visitClassFile(fileDetails);
    }
}
项目:Pushjet-Android    文件:SerializableCoffeeScriptCompileSpec.java   
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
项目:Pushjet-Android    文件:CopyFileVisitorImpl.java   
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : spec.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
项目:Pushjet-Android    文件:SyncCopyActionDecorator.java   
private void maybeDelete(FileVisitDetails fileDetails, boolean isDir) {
    RelativePath path = fileDetails.getRelativePath();
    if (!visited.contains(path)) {
        if (isDir) {
            GFileUtils.deleteDirectory(fileDetails.getFile());
        } else {
            GFileUtils.deleteQuietly(fileDetails.getFile());
        }
        didWork = true;
    }
}
项目:Pushjet-Android    文件:JarSnapshotter.java   
JarSnapshot createSnapshot(FileTree archivedClasses) {
    final Map<String, byte[]> hashes = new HashMap<String, byte[]>();
    archivedClasses.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            hashes.put(fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", ""), hasher.hash(fileDetails.getFile()));
        }
    });
    return new JarSnapshot(hashes);
}
项目:Pushjet-Android    文件:AllFromJarRebuildInfo.java   
private static Set<String> classesInJar(FileTree jarContents) {
    final Set<String> out = new HashSet<String>();
    jarContents.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}
        public void visitFile(FileVisitDetails fileDetails) {
            out.add(fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", ""));
        }
    });
    return out;
}
项目:Pushjet-Android    文件:DefaultTestClassScanner.java   
private void detectionScan() {
    testFrameworkDetector.startDetection(testClassProcessor);
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            testFrameworkDetector.processTestClass(fileDetails.getFile());
        }
    });
}
项目:Pushjet-Android    文件:DefaultTestClassScanner.java   
private void filenameScan() {
    candidateClassFiles.visit(new ClassFileVisitor() {
        public void visitClassFile(FileVisitDetails fileDetails) {
            String className = fileDetails.getRelativePath().getPathString().replaceAll("\\.class", "").replace('/', '.');
            TestClassRunInfo testClass = new DefaultTestClassRunInfo(className);
            testClassProcessor.processTestClass(testClass);
        }
    });
}