Search in sources :

Example 1 with TargetPlatformFilter

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

the class TargetPlatformFilterConfigurationReaderTest method testValidRemoveAllFilters.

public void testValidRemoveAllFilters() throws Exception {
    Xpp3Dom filterConfig = getTargetFilters("targetfilter/valid_removeAll/pom.xml");
    List<TargetPlatformFilter> filters = subject.parseFilterConfiguration(filterConfig);
    for (TargetPlatformFilter filter : filters) {
        assertThat(filter.getAction(), is(FilterAction.REMOVE_ALL));
    }
    assertThat(filters.get(0).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.servletbridge.extensionbundle")));
    assertThat(filters.get(1).getScopePattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.app", "[3.6.0,3.6.1)")));
    assertThat(filters.get(2).getScopePattern(), is(patternWithVersion(CapabilityType.P2_INSTALLABLE_UNIT, "a.jre.javase", "1.7.0")));
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 2 with TargetPlatformFilter

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

the class TargetPlatformFilterConfigurationReaderTest method testValidRestrictToFilters.

public void testValidRestrictToFilters() throws Exception {
    Xpp3Dom filterConfig = getTargetFilters("targetfilter/valid_restrictTo/pom.xml");
    List<TargetPlatformFilter> filters = subject.parseFilterConfiguration(filterConfig);
    for (TargetPlatformFilter filter : filters) {
        assertThat(filter.getAction(), is(FilterAction.RESTRICT));
    }
    assertThat(filters.get(0).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi")));
    assertThat(filters.get(0).getActionPattern(), is(patternWithVersionRange(null, null, "[3.6,3.7)")));
    assertThat(filters.get(1).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi")));
    assertThat(filters.get(1).getActionPattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi", "[3.6,3.7)")));
    assertThat(filters.get(2).getScopePattern(), is(patternWithoutVersion(CapabilityType.JAVA_PACKAGE, "javax.persistence")));
    assertThat(filters.get(2).getActionPattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "javax.persistence", "2.0")));
    assertThat(filters.get(3).getScopePattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.app", "[3.6.0,3.7.0)")));
    assertThat(filters.get(3).getActionPattern(), is(patternWithVersion(null, null, "3.6.2.v00000000")));
    assertThat(filters.get(4).getScopePattern(), is(patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "a.jre.javase")));
    assertThat(filters.get(4).getActionPattern(), is(patternWithVersion(null, null, "1.5.0")));
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 3 with TargetPlatformFilter

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

the class TargetPlatformFactoryImpl method createTargetPlatform.

/**
 * Computes the target platform from the given configuration and content.
 *
 * <p>
 * Used as entry point for tests, which can provide the execution environment configuration via
 * the more low-level type {@link ExecutionEnvironmentResolutionHandler}.
 * </p>
 *
 * @param tpConfiguration
 * @param eeResolutionHandler
 *            Representation of the target execution environment profile. In case of a custom EE
 *            profile, the handler also reads the full specification from the target platform.
 * @param reactorProjects
 *            may be <code>null</code>
 * @param pomDependencies
 *            may be <code>null</code>
 *
 * @see #createTargetPlatform(TargetPlatformConfigurationStub,
 *      ExecutionEnvironmentConfiguration, List, PomDependencyCollector)
 */
public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentResolutionHandler eeResolutionHandler, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
    List<TargetDefinitionContent> targetFileContent = resolveTargetDefinitions(tpConfiguration, eeResolutionHandler.getResolutionHints());
    PomDependencyCollectorImpl pomDependenciesContent = (PomDependencyCollectorImpl) pomDependencies;
    // TODO 412416 remove when the RepositoryBlackboardKey registration is gone
    if (pomDependenciesContent == null)
        pomDependenciesContent = new PomDependencyCollectorImpl(mavenContext);
    // TODO 372780 get rid of this special handling of pomDependency artifacts: there should be one p2 artifact repo view on the target platform
    IRawArtifactFileProvider pomDependencyArtifactRepo = pomDependenciesContent.getArtifactRepoOfPublishedBundles();
    RepositoryBlackboardKey blackboardKey = RepositoryBlackboardKey.forResolutionContextArtifacts(pomDependenciesContent.getProjectLocation());
    ArtifactRepositoryBlackboard.putRepository(blackboardKey, new ProviderOnlyArtifactRepository(pomDependencyArtifactRepo, Activator.getProvisioningAgent(), blackboardKey.toURI()));
    logger.debug("Registered artifact repository " + blackboardKey);
    Set<MavenRepositoryLocation> completeRepositories = tpConfiguration.getP2Repositories();
    registerRepositoryIDs(completeRepositories);
    // collect & process metadata
    boolean includeLocalMavenRepo = shouldIncludeLocallyInstalledUnits(tpConfiguration);
    LinkedHashSet<IInstallableUnit> externalUIs = gatherExternalInstallableUnits(completeRepositories, targetFileContent, pomDependenciesContent, includeLocalMavenRepo);
    Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(reactorProjects);
    List<TargetPlatformFilter> iuFilters = tpConfiguration.getFilters();
    TargetPlatformFilterEvaluator filter = !iuFilters.isEmpty() ? new TargetPlatformFilterEvaluator(iuFilters, logger) : null;
    applyConfiguredFilter(filter, reactorProjectUIs.keySet());
    applyFilters(filter, externalUIs, reactorProjectUIs.keySet(), eeResolutionHandler.getResolutionHints());
    PreliminaryTargetPlatformImpl targetPlatform = new // 
    PreliminaryTargetPlatformImpl(// 
    reactorProjectUIs, // 
    externalUIs, // 
    pomDependenciesContent.getMavenInstallableUnits(), // 
    eeResolutionHandler.getResolutionHints(), // 
    filter, // 
    localMetadataRepository, createExternalArtifactProvider(completeRepositories, targetFileContent, pomDependencyArtifactRepo, // 
    tpConfiguration.getIncludePackedArtifacts()), // 
    localArtifactRepository, // 
    includeLocalMavenRepo, logger);
    eeResolutionHandler.readFullSpecification(targetPlatform.getInstallableUnits());
    return targetPlatform;
}
Also used : IRawArtifactFileProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) RepositoryBlackboardKey(org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey) TargetPlatformFilterEvaluator(org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ProviderOnlyArtifactRepository(org.eclipse.tycho.repository.p2base.artifact.repository.ProviderOnlyArtifactRepository) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 4 with TargetPlatformFilter

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

the class TargetPlatformFactoryTest method testConfiguredFiltersOnReactorIUsInPreliminaryTP.

// TODO 372035 test logging for potential bugs in the explicit filters configuration
@Test
public void testConfiguredFiltersOnReactorIUsInPreliminaryTP() throws Exception {
    TargetPlatformFilter filter = TargetPlatformFilter.removeAllFilter(CapabilityPattern.patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "iu.p2.inf"));
    tpConfig.addFilters(Arrays.asList(filter));
    ReactorProject reactorProject = createReactorProject("artifactId", "test.feature.feature.group", "iu.p2.inf");
    P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, Collections.singletonList(reactorProject), null);
    assertThat(preliminaryTP.getInstallableUnits(), hasItem(unitWithId("test.feature.feature.group")));
    assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unitWithId("iu.p2.inf"))));
}
Also used : ReactorProject(org.eclipse.tycho.ReactorProject) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter) Test(org.junit.Test)

Example 5 with TargetPlatformFilter

use of org.eclipse.tycho.artifacts.TargetPlatformFilter 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)

Aggregations

TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)15 Test (org.junit.Test)11 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 ReactorProjectIdentities (org.eclipse.tycho.ReactorProjectIdentities)2 HashMap (java.util.HashMap)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 CapabilityPattern (org.eclipse.tycho.artifacts.TargetPlatformFilter.CapabilityPattern)1 TargetPlatformFilterSyntaxException (org.eclipse.tycho.artifacts.TargetPlatformFilterSyntaxException)1 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)1 PomDependencyCollector (org.eclipse.tycho.p2.target.facade.PomDependencyCollector)1 TargetPlatformFilterEvaluator (org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator)1 IRawArtifactFileProvider (org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider)1 ProviderOnlyArtifactRepository (org.eclipse.tycho.repository.p2base.artifact.repository.ProviderOnlyArtifactRepository)1 RepositoryBlackboardKey (org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey)1