Java Code Examples for org.gradle.api.tasks.util.PatternSet
The following examples show how to use
org.gradle.api.tasks.util.PatternSet.
These examples are extracted from open source projects.
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 Project: pushfish-android Author: PushFish File: DefaultScalaJavaJointCompiler.java License: BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(ScalaJavaJointCompileSpec spec) { scalaCompiler.execute(spec); PatternFilterable patternSet = new PatternSet(); patternSet.include("**/*.java"); FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet); if (!javaSource.isEmpty()) { spec.setSource(javaSource); javaCompiler.execute(spec); } return new WorkResult() { public boolean getDidWork() { return true; } }; }
Example #2
Source Project: pushfish-android Author: PushFish File: WindowsResourcesCompileTaskConfig.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) { task.setDescription(String.format("Compiles resources of the %s of %s", sourceSet, binary)); task.setToolChain(binary.getToolChain()); task.setTargetPlatform(binary.getTargetPlatform()); task.includes(new Callable<Set<File>>() { public Set<File> call() { return sourceSet.getExportedHeaders().getSrcDirs(); } }); task.source(sourceSet.getSource()); final Project project = task.getProject(); task.setOutputDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + ((LanguageSourceSetInternal) sourceSet).getFullName())); PreprocessingTool rcCompiler = (PreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("rcCompiler"); task.setMacros(rcCompiler.getMacros()); task.setCompilerArgs(rcCompiler.getArgs()); FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res")); binary.getTasks().getCreateOrLink().source(resourceOutputs); if (binary instanceof StaticLibraryBinarySpecInternal) { ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs); } }
Example #3
Source Project: pushfish-android Author: PushFish File: FileCollectionBackedArchiveTextResource.java License: BSD 2-Clause "Simplified" License | 6 votes |
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations, final TemporaryFileProvider tempFileProvider, final FileCollection fileCollection, final String path, Charset charset) { super(tempFileProvider, new LazilyInitializedFileTree() { @Override public FileTree createDelegate() { File archiveFile = fileCollection.getSingleFile(); String fileExtension = Files.getFileExtension(archiveFile.getName()); FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip") ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile); PatternSet patternSet = new PatternSet(); patternSet.include(path); return archiveContents.matching(patternSet); } public TaskDependency getBuildDependencies() { return fileCollection.getBuildDependencies(); } }, charset); }
Example #4
Source Project: pushfish-android Author: PushFish File: DefaultScalaJavaJointCompiler.java License: BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(ScalaJavaJointCompileSpec spec) { scalaCompiler.execute(spec); PatternFilterable patternSet = new PatternSet(); patternSet.include("**/*.java"); FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet); if (!javaSource.isEmpty()) { spec.setSource(javaSource); javaCompiler.execute(spec); } return new WorkResult() { public boolean getDidWork() { return true; } }; }
Example #5
Source Project: Pushjet-Android Author: Pushjet File: DefaultScalaJavaJointCompiler.java License: BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(ScalaJavaJointCompileSpec spec) { scalaCompiler.execute(spec); PatternFilterable patternSet = new PatternSet(); patternSet.include("**/*.java"); FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet); if (!javaSource.isEmpty()) { spec.setSource(javaSource); javaCompiler.execute(spec); } return new WorkResult() { public boolean getDidWork() { return true; } }; }
Example #6
Source Project: Pushjet-Android Author: Pushjet File: IncrementalCompilationInitializer.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) { if (staleClasses.isEmpty()) { spec.setSource(new SimpleFileCollection()); return; //do nothing. No classes need recompilation. } PatternSet classesToDelete = new PatternSet(); PatternSet sourceToCompile = new PatternSet(); preparePatterns(staleClasses, classesToDelete, sourceToCompile); //selectively configure the source spec.setSource(spec.getSource().getAsFileTree().matching(sourceToCompile)); //since we're compiling selectively we need to include the classes compiled previously spec.setClasspath(Iterables.concat(spec.getClasspath(), asList(spec.getDestinationDir()))); //get rid of stale files FileTree deleteMe = fileOperations.fileTree(spec.getDestinationDir()).matching(classesToDelete); fileOperations.delete(deleteMe); }
Example #7
Source Project: Pushjet-Android Author: Pushjet File: WindowsResourcesCompileTaskConfig.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) { task.setDescription(String.format("Compiles resources of the %s of %s", sourceSet, binary)); task.setToolChain(binary.getToolChain()); task.setTargetPlatform(binary.getTargetPlatform()); task.includes(new Callable<Set<File>>() { public Set<File> call() { return sourceSet.getExportedHeaders().getSrcDirs(); } }); task.source(sourceSet.getSource()); final Project project = task.getProject(); task.setOutputDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + ((LanguageSourceSetInternal) sourceSet).getFullName())); PreprocessingTool rcCompiler = (PreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("rcCompiler"); task.setMacros(rcCompiler.getMacros()); task.setCompilerArgs(rcCompiler.getArgs()); FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res")); binary.getTasks().getCreateOrLink().source(resourceOutputs); if (binary instanceof StaticLibraryBinarySpecInternal) { ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs); } }
Example #8
Source Project: Pushjet-Android Author: Pushjet File: FileCollectionBackedArchiveTextResource.java License: BSD 2-Clause "Simplified" License | 6 votes |
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations, final TemporaryFileProvider tempFileProvider, final FileCollection fileCollection, final String path, Charset charset) { super(tempFileProvider, new LazilyInitializedFileTree() { @Override public FileTree createDelegate() { File archiveFile = fileCollection.getSingleFile(); String fileExtension = Files.getFileExtension(archiveFile.getName()); FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip") ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile); PatternSet patternSet = new PatternSet(); patternSet.include(path); return archiveContents.matching(patternSet); } public TaskDependency getBuildDependencies() { return fileCollection.getBuildDependencies(); } }, charset); }
Example #9
Source Project: Pushjet-Android Author: Pushjet File: DefaultScalaJavaJointCompiler.java License: BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(ScalaJavaJointCompileSpec spec) { scalaCompiler.execute(spec); PatternFilterable patternSet = new PatternSet(); patternSet.include("**/*.java"); FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet); if (!javaSource.isEmpty()) { spec.setSource(javaSource); javaCompiler.execute(spec); } return new WorkResult() { public boolean getDidWork() { return true; } }; }
Example #10
Source Project: pushfish-android Author: PushFish File: IncrementalCompilationInitializer.java License: BSD 2-Clause "Simplified" License | 5 votes |
void preparePatterns(Collection<String> staleClasses, PatternSet classesToDelete, PatternSet sourceToCompile) { assert !staleClasses.isEmpty(); //if stale classes are empty (e.g. nothing to recompile), the patterns will not have any includes and will match all (e.g. recompile everything). for (String staleClass : staleClasses) { String path = staleClass.replaceAll("\\.", "/"); classesToDelete.include(path.concat(".class")); classesToDelete.include(path.concat("$*.class")); //the stale class might be a source class that was deleted //it's no harm to include it in sourceToCompile anyway sourceToCompile.include(path.concat(".java")); } }
Example #11
Source Project: pushfish-android Author: PushFish File: SingleIncludePatternFileTree.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void doVisit(FileVisitor visitor, File file, LinkedList<String> relativePath, int segmentIndex, AtomicBoolean stopFlag) { if (stopFlag.get()) { return; } String segment = patternSegments.get(segmentIndex); if (segment.contains("**")) { PatternSet patternSet = new PatternSet(); patternSet.include(includePattern); patternSet.exclude(excludeSpec); DirectoryFileTree fileTree = new DirectoryFileTree(baseDir, patternSet); fileTree.visitFrom(visitor, file, new RelativePath(file.isFile(), relativePath.toArray(new String[relativePath.size()]))); } else if (segment.contains("*") || segment.contains("?")) { PatternStep step = PatternStepFactory.getStep(segment, false); File[] children = file.listFiles(); if (children == null) { if (!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)); } for (File child : children) { if (stopFlag.get()) { break; } if (step.matches(child.getName())) { relativePath.addLast(child.getName()); doVisitDirOrFile(visitor, child, relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } } } else { relativePath.addLast(segment); doVisitDirOrFile(visitor, new File(file, segment), relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } }
Example #12
Source Project: pushfish-android Author: PushFish File: DefaultCopySpec.java License: BSD 2-Clause "Simplified" License | 5 votes |
public DefaultCopySpec(FileResolver resolver, Instantiator instantiator) { this.fileResolver = resolver; this.instantiator = instantiator; sourcePaths = new LinkedHashSet<Object>(); childSpecs = new ArrayList<CopySpecInternal>(); patternSet = new PatternSet(); duplicatesStrategy = null; }
Example #13
Source Project: pushfish-android Author: PushFish File: DefaultCopySpec.java License: BSD 2-Clause "Simplified" License | 5 votes |
public PatternSet getPatternSet() { PatternSet patterns = new PatternSet(); patterns.setCaseSensitive(isCaseSensitive()); patterns.include(this.getAllIncludes()); patterns.includeSpecs(getAllIncludeSpecs()); patterns.exclude(this.getAllExcludes()); patterns.excludeSpecs(getAllExcludeSpecs()); return patterns; }
Example #14
Source Project: pushfish-android Author: PushFish File: AbstractFileCollection.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** * 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()) { PatternSet patternSet = new PatternSet(); patternSet.include(new String[]{file.getName()}); fileTrees.add(new DirectoryFileTree(file.getParentFile(), patternSet)); } } return fileTrees; }
Example #15
Source Project: pushfish-android Author: PushFish File: SingleIncludePatternFileTree.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void doVisit(FileVisitor visitor, File file, LinkedList<String> relativePath, int segmentIndex, AtomicBoolean stopFlag) { if (stopFlag.get()) { return; } String segment = patternSegments.get(segmentIndex); if (segment.contains("**")) { PatternSet patternSet = new PatternSet(); patternSet.include(includePattern); patternSet.exclude(excludeSpec); DirectoryFileTree fileTree = new DirectoryFileTree(baseDir, patternSet); fileTree.visitFrom(visitor, file, new RelativePath(file.isFile(), relativePath.toArray(new String[relativePath.size()]))); } else if (segment.contains("*") || segment.contains("?")) { PatternStep step = PatternStepFactory.getStep(segment, false); File[] children = file.listFiles(); if (children == null) { if (!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)); } for (File child : children) { if (stopFlag.get()) { break; } if (step.matches(child.getName())) { relativePath.addLast(child.getName()); doVisitDirOrFile(visitor, child, relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } } } else { relativePath.addLast(segment); doVisitDirOrFile(visitor, new File(file, segment), relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } }
Example #16
Source Project: Pushjet-Android Author: Pushjet File: AbstractFileCollection.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** * 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()) { PatternSet patternSet = new PatternSet(); patternSet.include(new String[]{file.getName()}); fileTrees.add(new DirectoryFileTree(file.getParentFile(), patternSet)); } } return fileTrees; }
Example #17
Source Project: pushfish-android Author: PushFish File: DefaultCopySpec.java License: BSD 2-Clause "Simplified" License | 5 votes |
public DefaultCopySpec(FileResolver resolver, Instantiator instantiator, DefaultCopySpec parentSpec) { this.parentSpec = parentSpec; this.resolver = resolver; this.instantiator = instantiator; this.pathNotationParser = new PathNotationParser<String>(); sourcePaths = new LinkedHashSet<Object>(); childSpecs = new ArrayList<CopySpecInternal>(); patternSet = new PatternSet(); duplicatesStrategy = null; //inherit from parent }
Example #18
Source Project: Pushjet-Android Author: Pushjet File: DefaultRebuildInfo.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void configureCompilation(PatternSet changedSourceOnly, SelectiveJavaCompiler compiler, ClassDependencyInfo dependencyInfo) { for (String c : changedClassesInJar) { Set<String> actualDependents = dependencyInfo.getActualDependents(c); for (String d : actualDependents) { compiler.addStaleClass(d); changedSourceOnly.include(d.replaceAll("\\.", "/").concat(".java")); } } }
Example #19
Source Project: pushfish-android Author: PushFish File: AbstractFileCollection.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** * 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()) { PatternSet patternSet = new PatternSet(); patternSet.include(new String[]{file.getName()}); fileTrees.add(new DirectoryFileTree(file.getParentFile(), patternSet)); } } return fileTrees; }
Example #20
Source Project: pushfish-android Author: PushFish File: SelectiveCompilation.java License: BSD 2-Clause "Simplified" License | 5 votes |
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination, final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler, Iterable<File> sourceDirs, final FileOperations operations) { this.operations = operations; this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher())); this.compiler = compiler; Clock clock = new Clock(); final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination); //load dependency info final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo(); //including only source java classes that were changed final PatternSet changedSourceOnly = new PatternSet(); InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo); inputs.outOfDate(action); inputs.removed(action); if (fullRebuildNeeded != null) { LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded); this.classpath = compileClasspath; this.source = source; return; } compiler.deleteStaleClasses(); Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles(); if (filesToCompile.isEmpty()) { this.compilationNeeded = false; this.classpath = compileClasspath; this.source = source; } else { this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination)); this.source = source.matching(changedSourceOnly); } LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes()); }
Example #21
Source Project: pushfish-android Author: PushFish File: DefaultRebuildInfo.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void configureCompilation(PatternSet changedSourceOnly, SelectiveJavaCompiler compiler, ClassDependencyInfo dependencyInfo) { for (String c : changedClassesInJar) { Set<String> actualDependents = dependencyInfo.getActualDependents(c); for (String d : actualDependents) { compiler.addStaleClass(d); changedSourceOnly.include(d.replaceAll("\\.", "/").concat(".java")); } } }
Example #22
Source Project: gradle-plugins Author: freefair File: CompressFileOperationsImpl.java License: MIT License | 5 votes |
public CompressFileOperationsImpl(ProjectInternal project) { fileOperations = project.getFileOperations(); temporaryFileProvider = project.getServices().get(TemporaryFileProvider.class); fileHasher = project.getServices().get(FileHasher.class); fileSystem = project.getServices().get(FileSystem.class); directoryFileTreeFactory = project.getServices().get(DirectoryFileTreeFactory.class); patternSetFactory = project.getServices().getFactory(PatternSet.class); }
Example #23
Source Project: DexKnifePlugin Author: ceabie File: DexSplitTools.java License: Apache License 2.0 | 5 votes |
private static Spec<FileTreeElement> getMaindexSpec(PatternSet patternSet) { Spec<FileTreeElement> maindexSpec = null; if (patternSet != null) { Spec<FileTreeElement> includeSpec = null; Spec<FileTreeElement> excludeSpec = null; if (!patternSet.getIncludes().isEmpty()) { includeSpec = patternSet.getAsIncludeSpec(); } if (!patternSet.getExcludes().isEmpty()) { excludeSpec = patternSet.getAsExcludeSpec(); } if (includeSpec != null && excludeSpec != null) { maindexSpec = new OrSpec<>(includeSpec, new NotSpec<>(excludeSpec)); } else { if (excludeSpec != null) { // only exclude maindexSpec = new NotSpec<>(excludeSpec); } else if (includeSpec != null) { // only include maindexSpec = includeSpec; } } } // if (maindexSpec == null) { // maindexSpec = Specs.satisfyAll(); // } return maindexSpec; }
Example #24
Source Project: DexKnifePlugin Author: ceabie File: DexSplitTools.java License: Apache License 2.0 | 5 votes |
/** * Gets main classes from jar. * * @param jarMergingOutputFile the jar merging output file * @param mainDexPattern the main dex pattern * @param adtMainCls the filter mapping of suggest classes * @param logFilter * @return the main classes from jar * @throws Exception the exception * @author ceabie */ private static ArrayList<String> getMainClassesFromJar( File jarMergingOutputFile, PatternSet mainDexPattern, Map<String, Boolean> adtMainCls, boolean logFilter) throws Exception { ZipFile clsFile = new ZipFile(jarMergingOutputFile); Spec<FileTreeElement> asSpec = getMaindexSpec(mainDexPattern); ClassFileTreeElement treeElement = new ClassFileTreeElement(); // lists classes from jar. ArrayList<String> mainDexList = new ArrayList<>(); Enumeration<? extends ZipEntry> entries = clsFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String entryName = entry.getName(); if (entryName.endsWith(CLASS_SUFFIX)) { treeElement.setClassPath(entryName); if (isAtMainDex(adtMainCls, entryName, treeElement, asSpec, logFilter)) { mainDexList.add(entryName); } } } clsFile.close(); return mainDexList; }
Example #25
Source Project: DexKnifePlugin Author: ceabie File: DexSplitTools.java License: Apache License 2.0 | 5 votes |
/** * Gets main classes from mapping. * * @param mapping the mapping file * @param mainDexPattern the main dex pattern * @param recommendMainCls the filter mapping of suggest classes * @param logFilter * @return the main classes from mapping * @throws Exception the exception * @author ceabie */ private static List<String> getMainClassesFromMapping( File mapping, PatternSet mainDexPattern, Map<String, Boolean> recommendMainCls, boolean logFilter) throws Exception { String line; List<String> mainDexList = new ArrayList<>(); BufferedReader reader = new BufferedReader(new FileReader(mapping)); // all classes ClassFileTreeElement filterElement = new ClassFileTreeElement(); Spec<FileTreeElement> asSpec = getMaindexSpec(mainDexPattern); while ((line = reader.readLine()) != null) { line = line.trim(); if (line.endsWith(":")) { int flagPos = line.indexOf(MAPPING_FLAG); if (flagPos != -1) { String sOrgCls = line.substring(0, flagPos).replace('.', '/') + CLASS_SUFFIX; String sMapCls = line.substring(flagPos + MAPPING_FLAG_LEN, line.length() - 1) .replace('.', '/') + CLASS_SUFFIX; filterElement.setClassPath(sOrgCls); if (isAtMainDex(recommendMainCls, sMapCls, filterElement, asSpec, logFilter)) { mainDexList.add(sMapCls); } } } } reader.close(); return mainDexList; }
Example #26
Source Project: gradle-git-publish Author: ajoberstar File: GitPublishExtension.java License: Apache License 2.0 | 5 votes |
public GitPublishExtension(Project project) { this.repoDir = project.getObjects().directoryProperty(); this.repoUri = project.getObjects().property(String.class); this.referenceRepoUri = project.getObjects().property(String.class); this.branch = project.getObjects().property(String.class); this.commitMessage = project.getObjects().property(String.class); this.sign = project.getObjects().property(Boolean.class); this.contents = project.copySpec(); this.preserve = new PatternSet(); this.preserve.include(".git/**/*"); }
Example #27
Source Project: gradle-plugins Author: freefair File: CompressFileOperationsImpl.java License: MIT License | 5 votes |
public CompressFileOperationsImpl(ProjectInternal project) { fileOperations = project.getFileOperations(); temporaryFileProvider = project.getServices().get(TemporaryFileProvider.class); fileHasher = project.getServices().get(FileHasher.class); fileSystem = project.getServices().get(FileSystem.class); directoryFileTreeFactory = project.getServices().get(DirectoryFileTreeFactory.class); patternSetFactory = project.getServices().getFactory(PatternSet.class); }
Example #28
Source Project: Pushjet-Android Author: Pushjet File: SingleIncludePatternFileTree.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void doVisit(FileVisitor visitor, File file, LinkedList<String> relativePath, int segmentIndex, AtomicBoolean stopFlag) { if (stopFlag.get()) { return; } String segment = patternSegments.get(segmentIndex); if (segment.contains("**")) { PatternSet patternSet = new PatternSet(); patternSet.include(includePattern); patternSet.exclude(excludeSpec); DirectoryFileTree fileTree = new DirectoryFileTree(baseDir, patternSet); fileTree.visitFrom(visitor, file, new RelativePath(file.isFile(), relativePath.toArray(new String[relativePath.size()]))); } else if (segment.contains("*") || segment.contains("?")) { PatternStep step = PatternStepFactory.getStep(segment, false); File[] children = file.listFiles(); if (children == null) { if (!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)); } for (File child : children) { if (stopFlag.get()) { break; } if (step.matches(child.getName())) { relativePath.addLast(child.getName()); doVisitDirOrFile(visitor, child, relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } } } else { relativePath.addLast(segment); doVisitDirOrFile(visitor, new File(file, segment), relativePath, segmentIndex + 1, stopFlag); relativePath.removeLast(); } }
Example #29
Source Project: Pushjet-Android Author: Pushjet File: DefaultCopySpec.java License: BSD 2-Clause "Simplified" License | 5 votes |
public DefaultCopySpec(FileResolver resolver, Instantiator instantiator) { this.fileResolver = resolver; this.instantiator = instantiator; sourcePaths = new LinkedHashSet<Object>(); childSpecs = new ArrayList<CopySpecInternal>(); patternSet = new PatternSet(); duplicatesStrategy = null; }
Example #30
Source Project: Pushjet-Android Author: Pushjet File: DefaultCopySpec.java License: BSD 2-Clause "Simplified" License | 5 votes |
public PatternSet getPatternSet() { PatternSet patterns = new PatternSet(); patterns.setCaseSensitive(isCaseSensitive()); patterns.include(this.getAllIncludes()); patterns.includeSpecs(getAllIncludeSpecs()); patterns.exclude(this.getAllExcludes()); patterns.excludeSpecs(getAllExcludeSpecs()); return patterns; }