Java 类org.gradle.api.tasks.util.PatternSet 实例源码

项目:Reer    文件:DefaultScalaJavaJointCompiler.java   
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;
        }
    };
}
项目:Reer    文件:IncrementalCompilationInitializer.java   
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
    if (staleClasses.isEmpty()) {
        spec.setSource(new SimpleFileCollection());
        return; //do nothing. No classes need recompilation.
    }

    Factory<PatternSet> patternSetFactory = fileOperations.getFileResolver().getPatternSetFactory();
    PatternSet classesToDelete = patternSetFactory.create();
    PatternSet sourceToCompile = patternSetFactory.create();

    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);
}
项目:Reer    文件:SourceCompileTaskConfig.java   
@Override
protected void configureCompileTask(AbstractNativeCompileTask abstractTask, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    AbstractNativeSourceCompileTask task = (AbstractNativeSourceCompileTask) abstractTask;

    task.setDescription("Compiles the " + sourceSet + " of " + binary);

    task.source(sourceSet.getSource());

    final Project project = task.getProject();
    task.setObjectFileDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), sourceSet.getProjectScopedName()));

    // If this task uses a pre-compiled header
    if (sourceSet instanceof DependentSourceSetInternal && ((DependentSourceSetInternal) sourceSet).getPreCompiledHeader() != null) {
        final DependentSourceSetInternal dependentSourceSet = (DependentSourceSetInternal)sourceSet;
        PreCompiledHeader pch = binary.getPrefixFileToPCH().get(dependentSourceSet.getPrefixHeaderFile());
        pch.setPrefixHeaderFile(dependentSourceSet.getPrefixHeaderFile());
        pch.setIncludeString(dependentSourceSet.getPreCompiledHeader());
        task.setPreCompiledHeader(pch);
    }

    binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
}
项目:Reer    文件:WindowsResourcesCompileTaskConfig.java   
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
    task.setDescription("Compiles resources of the " + sourceSet + " of " + binary);

    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());

    task.includes(sourceSet.getExportedHeaders().getSourceDirectories());
    task.source(sourceSet.getSource());

    final Project project = task.getProject();
    task.setOutputDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), ((LanguageSourceSetInternal) sourceSet).getProjectScopedName()));

    PreprocessingTool rcCompiler = (PreprocessingTool) binary.getToolByName("rcCompiler");
    task.setMacros(rcCompiler.getMacros());
    task.setCompilerArgs(rcCompiler.getArgs());

    FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res"));
    binary.binaryInputs(resourceOutputs);
    if (binary instanceof StaticLibraryBinarySpecInternal) {
        ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs);
    }
}
项目:Reer    文件:PatternSpecFactory.java   
public Spec<FileTreeElement> createExcludeSpec(PatternSet patternSet) {
    List<Spec<FileTreeElement>> allExcludeSpecs = new ArrayList<Spec<FileTreeElement>>(2 + patternSet.getExcludeSpecs().size());

    if (!patternSet.getExcludes().isEmpty()) {
        allExcludeSpecs.add(createSpec(patternSet.getExcludes(), false, patternSet.isCaseSensitive()));
    }

    List<String> defaultExcludes = Arrays.asList(DirectoryScanner.getDefaultExcludes());
    if (!defaultExcludes.isEmpty()) {
        allExcludeSpecs.add(createSpec(defaultExcludes, false, patternSet.isCaseSensitive()));
    }

    allExcludeSpecs.addAll(patternSet.getExcludeSpecs());

    if (allExcludeSpecs.isEmpty()) {
        return Specs.satisfyNone();
    } else {
        return Specs.union(allExcludeSpecs);
    }
}
项目:Reer    文件:SingleIncludePatternFileTree.java   
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;
            }
            String childName = child.getName();
            if (step.matches(childName)) {
                relativePath.addLast(childName);
                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();
    }
}
项目:Pushjet-Android    文件:DefaultScalaJavaJointCompiler.java   
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;
        }
    };
}
项目:Pushjet-Android    文件:IncrementalCompilationInitializer.java   
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);
}
项目:Pushjet-Android    文件:WindowsResourcesCompileTaskConfig.java   
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);
    }
}
项目:Pushjet-Android    文件:FileCollectionBackedArchiveTextResource.java   
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);
}
项目:Pushjet-Android    文件:DefaultScalaJavaJointCompiler.java   
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;
        }
    };
}
项目:Reer    文件:IncrementalCompilationInitializer.java   
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"));
    }
}
项目:Reer    文件:SourceFoldersCreator.java   
private Set<String> collectFilters(Set<DirectoryTree> directoryTrees, File targetDir, String filterOperation) {
    for (DirectoryTree directoryTree : directoryTrees) {
        if (directoryTree.getDir().equals(targetDir)) {
            PatternSet patterns = directoryTree.getPatterns();
            return collectFilters(patterns, filterOperation);
        }
    }
    return Collections.emptySet();
}
项目:Reer    文件:PCHCompileTaskConfig.java   
@Override
protected void configureCompileTask(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal languageSourceSet) {
    // Note that the sourceSet is the sourceSet this pre-compiled header will be used with - it's not an
    // input sourceSet to the compile task.
    final DependentSourceSetInternal sourceSet = (DependentSourceSetInternal) languageSourceSet;

    task.setDescription("Compiles a pre-compiled header for the " + sourceSet + " of " + binary);

    // Add the source of the source set to the include paths to resolve any headers that may be in source directories
    task.includes(sourceSet.getSource().getSourceDirectories());

    final Project project = task.getProject();
    task.source(sourceSet.getPrefixHeaderFile());

    task.setObjectFileDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), languageSourceSet.getProjectScopedName() + "PCH"));

    task.dependsOn(project.getTasks().withType(PrefixHeaderFileGenerateTask.class).matching(new Spec<PrefixHeaderFileGenerateTask>() {
        @Override
        public boolean isSatisfiedBy(PrefixHeaderFileGenerateTask prefixHeaderFileGenerateTask) {
            return prefixHeaderFileGenerateTask.getPrefixHeaderFile().equals(sourceSet.getPrefixHeaderFile());
        }
    }));

    // This is so that VisualCpp has the object file of the generated source file available at link time
    binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));

    PreCompiledHeader pch = binary.getPrefixFileToPCH().get(sourceSet.getPrefixHeaderFile());
    pch.setPchObjects(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.pch", "**/*.gch")));
    pch.builtBy(task);
}
项目:Reer    文件:PatternSpecFactory.java   
public Spec<FileTreeElement> createIncludeSpec(PatternSet patternSet) {
    List<Spec<FileTreeElement>> allIncludeSpecs = new ArrayList<Spec<FileTreeElement>>(1 + patternSet.getIncludeSpecs().size());

    if (!patternSet.getIncludes().isEmpty()) {
        allIncludeSpecs.add(createSpec(patternSet.getIncludes(), true, patternSet.isCaseSensitive()));
    }

    allIncludeSpecs.addAll(patternSet.getIncludeSpecs());

    return Specs.union(allIncludeSpecs);
}
项目:Reer    文件:FileCollectionBackedArchiveTextResource.java   
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileCollection() {
        @Override
        public String getDisplayName() {
            return String.format("entry '%s' in archive %s", path, fileCollection);
        }

        @Override
        public FileCollection 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);
        }

        @Override
        public void visitDependencies(TaskDependencyResolveContext context) {
            context.add(fileCollection);
        }
    }, charset);
}
项目:Reer    文件:ImmutablePatternSet.java   
public static ImmutablePatternSet of(PatternSet source) {
    if (source instanceof ImmutablePatternSet) {
        return (ImmutablePatternSet) source;
    } else {
        return new ImmutablePatternSet(source);
    }
}
项目:Reer    文件:FileSystemSubset.java   
public Builder add(File dir, PatternSet patternSet) {
    lock.lock();
    try {
        trees.add(ImmutableDirectoryTree.of(dir, patternSet));
        return this;
    } finally {
        lock.unlock();
    }
}
项目:Reer    文件:DefaultDirectoryFileTreeFactory.java   
public DefaultDirectoryFileTreeFactory() {
    this.patternSetFactory = new Factory<PatternSet>() {
        @Override
        public PatternSet create() {
            return new PatternSet();
        }
    };
    this.fileSystem = FileSystems.getDefault();
}
项目:Reer    文件:DirectoryFileTree.java   
DirectoryFileTree(File dir, PatternSet patternSet, Factory<DirectoryWalker> directoryWalkerFactory, FileSystem fileSystem, boolean postfix) {
    this.patternSet = patternSet;
    this.dir = dir;
    this.directoryWalkerFactory = directoryWalkerFactory;
    this.fileSystem = fileSystem;
    this.postfix = postfix;
}
项目:Reer    文件:DefaultCopySpec.java   
public PatternSet getPatternSet() {
    PatternSet patterns = fileResolver.getPatternSetFactory().create();
    patterns.setCaseSensitive(isCaseSensitive());
    patterns.include(this.getAllIncludes());
    patterns.includeSpecs(getAllIncludeSpecs());
    patterns.exclude(this.getAllExcludes());
    patterns.excludeSpecs(getAllExcludeSpecs());
    return patterns;
}
项目:Reer    文件:SyncCopyActionDecorator.java   
private SyncCopyActionDecoratorFileVisitor(Set<RelativePath> visited, PatternFilterable preserveSpec) {
    this.visited = visited;
    PatternSet preserveSet = new PatternSet();
    if (preserveSpec != null) {
        preserveSet.include(preserveSpec.getIncludes());
        preserveSet.exclude(preserveSpec.getExcludes());
    }
    this.preserveSet = preserveSet;
    this.preserveSpec = preserveSet.getAsSpec();
}
项目:DexKnifePlugin    文件:DexSplitTools.java   
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;
    }
项目:DexKnifePlugin    文件:DexSplitTools.java   
/**
 * 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;
}
项目:DexKnifePlugin    文件:DexSplitTools.java   
/**
 * 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;
}
项目:Pushjet-Android    文件:IncrementalCompilationInitializer.java   
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"));
    }
}
项目:Pushjet-Android    文件:SingleIncludePatternFileTree.java   
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();
    }
}
项目:Pushjet-Android    文件:DefaultCopySpec.java   
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;
}
项目:Pushjet-Android    文件:DefaultCopySpec.java   
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;
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
/**
 * 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;
}
项目:Pushjet-Android    文件:SingleIncludePatternFileTree.java   
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();
    }
}
项目:Pushjet-Android    文件:DefaultCopySpec.java   
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
}
项目:Pushjet-Android    文件:DefaultCopySpec.java   
public PatternSet getPatternSet() {
    PatternSet patterns = new PatternSet();
    patterns.setCaseSensitive(isCaseSensitive());
    patterns.include(getAllIncludes());
    patterns.includeSpecs(getAllIncludeSpecs());
    patterns.exclude(getAllExcludes());
    patterns.excludeSpecs(getAllExcludeSpecs());
    return patterns;
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
/**
 * 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;
}
项目:Pushjet-Android    文件:SelectiveCompilation.java   
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());
}
项目:Pushjet-Android    文件:DefaultRebuildInfo.java   
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"));
        }
    }
}
项目:Reer    文件:JarArchive.java   
public JarArchive(File jar, FileTree contents, Factory<PatternSet> patternSetFactory) {
    this.file = jar;
    this.contents = contents.matching(patternSetFactory.create().include("**/*.class"));
}
项目:Reer    文件:SourceFoldersCreator.java   
private Set<String> collectFilters(PatternSet patterns, String filterOperation) {
    return Cast.<Set<String>>uncheckedCast(DynamicObjectUtil.asDynamicObject(patterns).getProperty(filterOperation));
}
项目:Reer    文件:AssembleTaskConfig.java   
private void configureAssembleTask(Assemble task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    task.setDescription("Assembles the " + sourceSet + " of " + binary);

    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());

    task.source(sourceSet.getSource());

    final Project project = task.getProject();
    task.setObjectFileDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), sourceSet.getProjectScopedName()));

    Tool assemblerTool = binary.getToolByName("assembler");
    task.setAssemblerArgs(assemblerTool.getArgs());

    binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
}
项目:Reer    文件:SourceTask.java   
@Inject
protected Factory<PatternSet> getPatternSetFactory() {
    throw new UnsupportedOperationException();
}