Package org.gradle.api.file

Examples of org.gradle.api.file.RelativePath


    @Test
    public void copyActionCanChangeFileDestinationPath() {
        FileCopyDetails copyDetails = expectActionExecutedWhenFileVisited();

        RelativePath newPath = new RelativePath(true, "new");
        copyDetails.setRelativePath(newPath);
        assertThat(copyDetails.getRelativePath(), equalTo(newPath));

        copyDetails.setPath("/a/b");
        assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "b")));

        copyDetails.setName("new name");
        assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "new name")));
    }
View Full Code Here


        DefaultPatternMatcher matcher = new DefaultPatternMatcher(true, true);
        List<PatternStep> steps = matcher.getStepsForTest();
        assertEquals(0, steps.size());

        // both empty
        RelativePath path = new RelativePath(true);
        assertTrue(matcher.isSatisfiedBy(path));

        // empty matcher, non-empty path
        path = new RelativePath(true, "a");
        assertFalse(matcher.isSatisfiedBy(path));

        // non-empty matcher, empty path
        matcher = new DefaultPatternMatcher(true, true, "a");
        path = new RelativePath(true);
        assertFalse(matcher.isSatisfiedBy(path));

    }
View Full Code Here

    }

    @Test public void testLiterals() {
        matcher = new DefaultPatternMatcher(true, true, "a");
        path = new RelativePath(true, "a");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "b");
        assertFalse(matcher.isSatisfiedBy(path));
       
        matcher = new DefaultPatternMatcher(true, true, "a", "b");
        path = new RelativePath(true, "a", "b");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "c");
        assertFalse(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "b", "c");
        assertFalse(matcher.isSatisfiedBy(path));

        // short path
        path = new RelativePath(true, "a");
        assertFalse(matcher.isSatisfiedBy(path));

        // long path
        path = new RelativePath(true, "a", "b", "c");
        assertFalse(matcher.isSatisfiedBy(path));
    }
View Full Code Here

        assertFalse(matcher.isSatisfiedBy(path));
    }

    @Test public void testPartials() {
        matcher = new DefaultPatternMatcher(true, true, "a", "b", "c");
        path = new RelativePath(false, "a", "b");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "b");
        assertFalse(matcher.isSatisfiedBy(path));

        matcher = new DefaultPatternMatcher(false, true, "a", "b", "c");
        path = new RelativePath(false, "a", "b");
        assertFalse(matcher.isSatisfiedBy(path));

    }
View Full Code Here

    }

    @Test public void testWildCards() {
        matcher = new DefaultPatternMatcher(true, true, "*");
        path = new RelativePath(true, "anything");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "anything", "b");
        assertFalse(matcher.isSatisfiedBy(path));

        matcher = new DefaultPatternMatcher(true, true, "any??ing");
        path = new RelativePath(true, "anything");
        assertTrue(matcher.isSatisfiedBy(path));
    }
View Full Code Here

        assertTrue(matcher.isSatisfiedBy(path));
    }

    @Test public void testGreedy() {
        matcher = new DefaultPatternMatcher(true, true, "a","**");
        path = new RelativePath(true, "a", "b", "c");
        assertTrue(matcher.isSatisfiedBy(path));

        //leading greedy
        matcher = new DefaultPatternMatcher(true, true, "**", "c");
        path = new RelativePath(true, "a", "b", "c");
        assertTrue(matcher.isSatisfiedBy(path));
       
        path = new RelativePath(true, "a", "b", "d");
        assertFalse(matcher.isSatisfiedBy(path));

        // inner greedy
        matcher = new DefaultPatternMatcher(true, true, "a", "**", "c");
        path = new RelativePath(true, "a", "b", "c");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "aa", "bb", "c");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(false, "a", "aa", "bb", "d");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "aa", "bb", "d");
        assertFalse(matcher.isSatisfiedBy(path));

        // fake trail
        matcher = new DefaultPatternMatcher(true, true, "a", "**", "c", "d");
        path = new RelativePath(true, "a", "b", "c", "e", "c", "d");
        assertTrue(matcher.isSatisfiedBy(path));
       
        // multiple greedies
        matcher = new DefaultPatternMatcher(true, true, "a", "**", "c", "**", "e");
        path = new RelativePath(true, "a", "b", "c", "d", "e");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "b", "bb", "c", "d", "e");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "q", "bb", "c", "d", "c", "d", "e");
        assertTrue(matcher.isSatisfiedBy(path));

        // Missing greedy
        matcher = new DefaultPatternMatcher(true, true, "a", "**", "c");
        path = new RelativePath(true, "a", "c");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "a", "d");
        assertFalse(matcher.isSatisfiedBy(path));
    }
View Full Code Here

        assertFalse(matcher.isSatisfiedBy(path));
    }

    @Test public void testTypical() {
        matcher = new DefaultPatternMatcher(true, true, "**", "CVS", "*");
        path = new RelativePath(true, "CVS", "Repository");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "org", "gradle", "CVS", "Entries");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "org", "gradle", "CVS", "foo", "bar", "Entries");
        assertFalse(matcher.isSatisfiedBy(path));

        matcher = new DefaultPatternMatcher(true, true, "src", "main", "**");
        path = new RelativePath(true, "src", "main", "groovy", "org");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "src", "test", "groovy", "org");
        assertFalse(matcher.isSatisfiedBy(path));

        matcher = new DefaultPatternMatcher(true, true, "**", "test", "**");
        // below fails, trailing ** not ignored
        path = new RelativePath(true, "src", "main", "test");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "src", "test", "main");
        assertTrue(matcher.isSatisfiedBy(path));

        path = new RelativePath(true, "src", "main", "fred");
        assertFalse(matcher.isSatisfiedBy(path));
    }
View Full Code Here

        assertFalse(matcher.isSatisfiedBy(path));
    }

    @Test public void testCase() {
        matcher = new DefaultPatternMatcher(true, true, "a", "b");
        assertTrue(matcher.isSatisfiedBy(new RelativePath(true, "a", "b")));
        assertFalse(matcher.isSatisfiedBy(new RelativePath(true, "A", "B")));

        matcher = new DefaultPatternMatcher(true, false, "a", "b");
        assertTrue(matcher.isSatisfiedBy(new RelativePath(true, "a", "b")));
        assertTrue(matcher.isSatisfiedBy(new RelativePath(true, "A", "B")));
    }
View Full Code Here

    }

    @Test public void testNameOnly() {
        matcher = PatternMatcherFactory.getPatternMatcher(true, true, "**/*.jsp");
        assertTrue(matcher instanceof NameOnlyPatternMatcher);
        path = new RelativePath(true, "fred.jsp");
        assertTrue(matcher.isSatisfiedBy(path));
    }
View Full Code Here

        assertThat(matcher, not(matchesDir("a", "c", "b", "c")));
        assertThat(matcher, not(matchesDir("d", "a", "b")));
    }

    private Matcher<Spec<RelativePath>> matchesFile(String... paths) {
        return matches(new RelativePath(true, paths));
    }
View Full Code Here

TOP

Related Classes of org.gradle.api.file.RelativePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.