Java Code Examples for org.gradle.api.tasks.util.PatternSet#include()

The following examples show how to use org.gradle.api.tasks.util.PatternSet#include() . 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: FileCollectionBackedArchiveTextResource.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 2
Source File: FileCollectionBackedArchiveTextResource.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 3
Source File: SingleIncludePatternFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 4
Source File: DefaultCopySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 5
Source File: AbstractFileCollection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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 6
Source File: SingleIncludePatternFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 7
Source File: DefaultCopySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PatternSet getPatternSet() {
    PatternSet patterns = new PatternSet();
    patterns.setCaseSensitive(isCaseSensitive());
    patterns.include(getAllIncludes());
    patterns.includeSpecs(getAllIncludeSpecs());
    patterns.exclude(getAllExcludes());
    patterns.excludeSpecs(getAllExcludeSpecs());
    return patterns;
}
 
Example 8
Source File: AbstractFileCollection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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 9
Source File: DefaultRebuildInfo.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 10
Source File: SingleIncludePatternFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 11
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 12
Source File: AbstractFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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 13
Source File: SingleIncludePatternFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 14
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PatternSet getPatternSet() {
    PatternSet patterns = new PatternSet();
    patterns.setCaseSensitive(isCaseSensitive());
    patterns.include(getAllIncludes());
    patterns.includeSpecs(getAllIncludeSpecs());
    patterns.exclude(getAllExcludes());
    patterns.excludeSpecs(getAllExcludeSpecs());
    return patterns;
}
 
Example 15
Source File: AbstractFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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 16
Source File: DefaultRebuildInfo.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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"));
        }
    }
}