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")));
}
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")));
}
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;
}
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"))));
}
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);
}
Aggregations