use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.
the class TargetPlatformFactoryImpl method createTargetPlatformWithUpdatedReactorUnits.
P2TargetPlatform createTargetPlatformWithUpdatedReactorUnits(PreliminaryTargetPlatformImpl preliminaryTP, Map<IInstallableUnit, ReactorProjectIdentities> reactorUnitsMap, List<IRawArtifactFileProvider> reactorArtifacts) {
LinkedHashSet<IInstallableUnit> allUnits = preliminaryTP.getExternalUnits();
// external units are already filtered, only reactor units need to be filtered again
if (reactorUnitsMap != null) {
Collection<IInstallableUnit> reactorUnits = new LinkedList<>(reactorUnitsMap.keySet());
TargetPlatformFilterEvaluator configuredFilters = preliminaryTP.getFilter();
if (configuredFilters != null) {
configuredFilters.filterUnits(reactorUnits);
}
allUnits.addAll(reactorUnits);
}
IRawArtifactFileProvider jointArtifacts = createJointArtifactProvider(reactorArtifacts, preliminaryTP.getExternalArtifacts());
return new FinalTargetPlatformImpl(allUnits, preliminaryTP.getEEResolutionHints(), jointArtifacts, localArtifactRepository, preliminaryTP.getOriginalMavenArtifactMap(), reactorUnitsMap);
}
use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.
the class P2ResolverImpl method resolveMetadata.
@Override
public P2ResolutionResult resolveMetadata(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
P2TargetPlatform contextImpl = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
ResolutionDataImpl data = new ResolutionDataImpl(contextImpl.getEEResolutionHints());
data.setAvailableIUs(contextImpl.getInstallableUnits());
data.setRootIUs(new HashSet<IInstallableUnit>());
data.setAdditionalRequirements(additionalRequirements);
ProjectorResolutionStrategy strategy = new ProjectorResolutionStrategy(logger);
strategy.setData(data);
MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
try {
for (IInstallableUnit iu : strategy.multiPlatformResolve(environments, monitor)) {
result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
}
} catch (ResolverException e) {
logger.error("Resolution failed:");
new MultiLineLogger(logger).error(e.getDetails(), " ");
throw new RuntimeException(e);
}
return result;
}
use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.
the class P2ResolverImpl method getTargetPlatformAsResolutionResult.
// TODO 412416 make this obsolete by adding appropriate getters in TargetPlatform interface
@Override
public P2ResolutionResult getTargetPlatformAsResolutionResult(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
P2TargetPlatform targetPlatform = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
for (IInstallableUnit iu : targetPlatform.getInstallableUnits()) {
result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
}
return result;
}
use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.
the class TargetPlatformFactoryTest method testFinalTargetPlatformContainsPomDependencyIU.
@Test
public void testFinalTargetPlatformContainsPomDependencyIU() throws Exception {
PomDependencyCollector pomDependencies = subject.newPomDependencyCollector();
pomDependencies.addArtifactWithExistingMetadata(PomDependencyCollectorTest.artifactWithClassifier(null), PomDependencyCollectorTest.existingMetadata());
P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, pomDependencies);
P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, null, REACTOR_ARTIFACTS);
assertThat(finalTP.getInstallableUnits(), hasItem(unitWithId("test.unit")));
}
use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.
the class TargetPlatformFactoryTest method testConfiguredFiltersOnPomDependencies.
@Test
public void testConfiguredFiltersOnPomDependencies() throws Exception {
PomDependencyCollector pomDependencies = subject.newPomDependencyCollector();
pomDependencies.addArtifactWithExistingMetadata(PomDependencyCollectorTest.artifactWithClassifier(null), PomDependencyCollectorTest.existingMetadata());
TargetPlatformFilter filter = TargetPlatformFilter.removeAllFilter(CapabilityPattern.patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "test.unit"));
tpConfig.addFilters(Arrays.asList(filter));
P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, pomDependencies);
assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unitWithId("test.unit"))));
P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, null, REACTOR_ARTIFACTS);
assertThat(finalTP.getInstallableUnits(), not(hasItem(unitWithId("test.unit"))));
}
Aggregations