Search in sources :

Example 1 with CapabilityPattern

use of org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern in project tycho by eclipse.

the class TargetPlatformFilterEvaluatorTest method testRemoveAllOfUnitId.

@Test
public void testRemoveAllOfUnitId() throws Exception {
    CapabilityPattern unitIdPattern = patternWithVersion(CapabilityType.P2_INSTALLABLE_UNIT, "main.product.id", null);
    subject = newEvaluator(removeAllFilter(unitIdPattern));
    subject.filterUnits(workUnits);
    assertThat(removedUnits(), hasItem("main.product.id_0.0.1.201112271438"));
    assertThat(removedUnits(), hasSize(1));
}
Also used : CapabilityPattern(org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern) Test(org.junit.Test)

Example 2 with CapabilityPattern

use of org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern in project tycho by eclipse.

the class TargetPlatformFilterConfigurationReader method parseFilter.

private void parseFilter(Xpp3Dom filterDom, List<TargetPlatformFilter> result) {
    CapabilityPattern scopePattern = parseScopePattern(filterDom);
    Xpp3Dom restrictToDom = getComplexValue(filterDom, "restrictTo");
    Xpp3Dom removeAllDom = getMarker(filterDom, "removeAll");
    if (removeAllDom == null && restrictToDom == null) {
        throw new TargetPlatformFilterSyntaxException("Filter action is required: specify either 'filters.filter.removeAll' or 'filters.filter.restrictTo'");
    } else if (removeAllDom != null && restrictToDom != null) {
        throw new TargetPlatformFilterSyntaxException("Only one filter action may be specified: either 'filters.filter.removeAll' or 'filters.filter.restrictTo'");
    }
    final TargetPlatformFilter filter;
    if (removeAllDom != null) {
        filter = TargetPlatformFilter.removeAllFilter(scopePattern);
    } else {
        CapabilityPattern restrictionPattern = parseRestrictionPattern(restrictToDom);
        filter = TargetPlatformFilter.restrictionFilter(scopePattern, restrictionPattern);
    }
    result.add(filter);
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformFilterSyntaxException(org.eclipse.tycho.artifacts.TargetPlatformFilterSyntaxException) CapabilityPattern(org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 3 with CapabilityPattern

use of org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern in project tycho by eclipse.

the class TargetPlatformFilterEvaluatorTest method testUnitAndBundleIdDistinction.

@Test
public void testUnitAndBundleIdDistinction() throws Exception {
    // does not match because main.product.id is not a bundle
    CapabilityPattern bundleIdPattern = patternWithVersion(CapabilityType.OSGI_BUNDLE, "main.product.id", null);
    subject = newEvaluator(removeAllFilter(bundleIdPattern));
    subject.filterUnits(workUnits);
    assertThat(removedUnits(), hasSize(0));
}
Also used : CapabilityPattern(org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern) Test(org.junit.Test)

Aggregations

CapabilityPattern (org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern)3 Test (org.junit.Test)2 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)1 TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)1 TargetPlatformFilterSyntaxException (org.eclipse.tycho.artifacts.TargetPlatformFilterSyntaxException)1