Search in sources :

Example 1 with PatternFilterable

use of org.gradle.api.tasks.util.PatternFilterable in project gradle by gradle.

the class CompositeFileTreeTest method matchingWithActionReturnsUnionOfFilteredSets.

@Test
public void matchingWithActionReturnsUnionOfFilteredSets() {
    final Action<PatternFilterable> action = Actions.doNothing();
    final FileTreeInternal filtered1 = context.mock(FileTreeInternal.class);
    final FileTreeInternal filtered2 = context.mock(FileTreeInternal.class);
    context.checking(new Expectations() {

        {
            oneOf(source1).matching(action);
            will(returnValue(filtered1));
            oneOf(source2).matching(action);
            will(returnValue(filtered2));
        }
    });
    FileTree filtered = tree.matching(action);
    assertThat(filtered, instanceOf(CompositeFileTree.class));
    CompositeFileTree filteredCompositeSet = (CompositeFileTree) filtered;
    assertThat(toList(filteredCompositeSet.getSourceCollections()), equalTo(toList(filtered1, filtered2)));
}
Also used : Expectations(org.jmock.Expectations) FileTree(org.gradle.api.file.FileTree) PatternFilterable(org.gradle.api.tasks.util.PatternFilterable) Test(org.junit.Test)

Example 2 with PatternFilterable

use of org.gradle.api.tasks.util.PatternFilterable in project gradle by gradle.

the class FilteredFileTree method visitChildren.

@Override
protected void visitChildren(Consumer<FileCollectionInternal> visitor) {
    // For backwards compatibility, need to calculate the patterns on each query
    PatternFilterable patterns = getPatterns();
    tree.visitContentsAsFileTrees(child -> visitor.accept(child.matching(patterns)));
}
Also used : PatternFilterable(org.gradle.api.tasks.util.PatternFilterable)

Example 3 with PatternFilterable

use of org.gradle.api.tasks.util.PatternFilterable in project gradle by gradle.

the class DefaultScalaJavaJointCompiler method execute.

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;
        }
    };
}
Also used : FileTree(org.gradle.api.file.FileTree) WorkResult(org.gradle.api.tasks.WorkResult) PatternSet(org.gradle.api.tasks.util.PatternSet) PatternFilterable(org.gradle.api.tasks.util.PatternFilterable)

Aggregations

PatternFilterable (org.gradle.api.tasks.util.PatternFilterable)3 FileTree (org.gradle.api.file.FileTree)2 WorkResult (org.gradle.api.tasks.WorkResult)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1