org.gradle.api.file.FileVisitDetails Java Examples
The following examples show how to use
org.gradle.api.file.FileVisitDetails.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NonJavaccSourceFileVisitorTest.java From javaccPlugin with MIT License | 6 votes |
@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)); }
Example #2
Source File: DefaultJarSnapshotter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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())); }
Example #3
Source File: PathKeyFileStore.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #4
Source File: PathKeyFileStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #5
Source File: PathKeyFileStore.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #6
Source File: PathKeyFileStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #7
Source File: DefaultJarSnapshotter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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())); }
Example #8
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); } }); }
Example #9
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void visitFile(FileVisitDetails fileDetails) { final File file = fileDetails.getFile(); if (file.getAbsolutePath().endsWith(".class")) { visitClassFile(fileDetails); } }
Example #10
Source File: JarSnapshotter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #11
Source File: SyncCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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; } }
Example #12
Source File: CopyFileVisitorImpl.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #13
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void detectionScan() { testFrameworkDetector.startDetection(testClassProcessor); candidateClassFiles.visit(new ClassFileVisitor() { public void visitClassFile(FileVisitDetails fileDetails) { testFrameworkDetector.processTestClass(fileDetails.getFile()); } }); }
Example #14
Source File: SerializableCoffeeScriptCompileSpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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())); } }); }
Example #15
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); } }); }
Example #16
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void visitFile(FileVisitDetails fileDetails) { final File file = fileDetails.getFile(); if (file.getAbsolutePath().endsWith(".class")) { visitClassFile(fileDetails); } }
Example #17
Source File: DefaultTestClassScanner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void detectionScan() { testFrameworkDetector.startDetection(testClassProcessor); candidateClassFiles.visit(new ClassFileVisitor() { public void visitClassFile(FileVisitDetails fileDetails) { testFrameworkDetector.processTestClass(fileDetails.getFile()); } }); }
Example #18
Source File: AllFromJarRebuildInfo.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example #19
Source File: JavaccSourceFileVisitor.java From javaccPlugin with MIT License | 5 votes |
@Override public void visitFile(FileVisitDetails fileDetails) { if (isValidSourceFileForTask(fileDetails)) { compiler.compile(computeInputDirectory(fileDetails), fileDetails.getRelativePath()); } else { compiler.getLogger().debug("Skipping file {} as it is not supported by program {}", fileDetails.getFile().getAbsolutePath(), compiler.getProgramName()); } }
Example #20
Source File: NonJavaccSourceFileVisitorTest.java From javaccPlugin with MIT License | 5 votes |
@Test public void givenATextInputFileWhenVisitFileThenFileIsCopiedToTaskOutputDirectory() { FileVisitDetails fileDetails = mock(FileVisitDetails.class); when(fileDetails.getFile()).thenReturn(new File(inputDirectory, TEXT_INPUT_FILENAME)); when(fileDetails.getName()).thenReturn(TEXT_INPUT_FILENAME); sourceVisitor.visitFile(fileDetails); assertEquals(1, outputDirectory.list().length); assertTrue(Arrays.asList(outputDirectory.list()).contains(TEXT_INPUT_FILENAME)); }
Example #21
Source File: CopyFileVisitorImpl.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #22
Source File: ClassFilesAnalyzer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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()); }
Example #23
Source File: NonJavaccSourceFileVisitor.java From javaccPlugin with MIT License | 5 votes |
@Override public void visitFile(FileVisitDetails fileDetails) { if (!isValidSourceFileForTask(fileDetails)) { File sourceFile = fileDetails.getFile(); File destinationFile = new File(sourceFile.getAbsolutePath().replace(compiler.getInputDirectory().getAbsolutePath(), compiler.getOutputDirectory().getAbsolutePath())); copyFile(sourceFile, destinationFile); } }
Example #24
Source File: SerializableCoffeeScriptCompileSpec.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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())); } }); }
Example #25
Source File: JavaScriptMinify.java From playframework with Apache License 2.0 | 5 votes |
@Override public void visitFile(final FileVisitDetails fileDetails) { final File outputFileDir = new File(destinationDir.get().getAsFile(), fileDetails.getRelativePath().getParent().getPathString()); // Copy the raw form FileOperations fileOperations = ((ProjectInternal) getProject()).getFileOperations(); fileOperations.copy(copySpec -> copySpec.from(fileDetails.getFile()).into(outputFileDir)); // Capture the relative file relativeFiles.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath())); }
Example #26
Source File: DefaultTestClassScanner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void visitFile(FileVisitDetails fileDetails) { final File file = fileDetails.getFile(); if (file.getAbsolutePath().endsWith(".class")) { visitClassFile(fileDetails); } }
Example #27
Source File: DefaultTestClassScanner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); } }); }
Example #28
Source File: DefaultTestClassScanner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void detectionScan() { testFrameworkDetector.startDetection(testClassProcessor); candidateClassFiles.visit(new ClassFileVisitor() { public void visitClassFile(FileVisitDetails fileDetails) { testFrameworkDetector.processTestClass(fileDetails.getFile()); } }); }
Example #29
Source File: SerializableCoffeeScriptCompileSpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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())); } }); }
Example #30
Source File: NonJavaccSourceFileVisitorTest.java From javaccPlugin with MIT License | 5 votes |
@Test(expected = JavaccTaskException.class) public void givenAnUnexistingTextInputFileWhenVisitFileThenExceptionIsThrown() { FileVisitDetails fileDetails = mock(FileVisitDetails.class); when(fileDetails.getFile()).thenReturn(new File(UNEXISTING_INPUT_FILENAME)); when(fileDetails.getName()).thenReturn(UNEXISTING_INPUT_FILENAME); sourceVisitor.visitFile(fileDetails); }