use of org.eclipse.equinox.internal.p2.director.Projector in project tycho by eclipse.
the class ProjectorResolutionStrategy method resolve.
@Override
public Collection<IInstallableUnit> resolve(Map<String, String> properties, IProgressMonitor monitor) throws ResolverException {
Map<String, String> newSelectionContext = SimplePlanner.createSelectionContext(properties);
IQueryable<IInstallableUnit> slice = slice(properties, monitor);
Set<IInstallableUnit> seedUnits = new LinkedHashSet<>(data.getRootIUs());
List<IRequirement> seedRequires = new ArrayList<>();
if (data.getAdditionalRequirements() != null) {
seedRequires.addAll(data.getAdditionalRequirements());
}
// force profile UIs to be used during resolution
seedUnits.addAll(data.getEEResolutionHints().getMandatoryUnits());
seedRequires.addAll(data.getEEResolutionHints().getMandatoryRequires());
Projector projector = new Projector(slice, newSelectionContext, new HashSet<IInstallableUnit>(), false);
projector.encode(createUnitRequiring("tycho", seedUnits, seedRequires), EMPTY_IU_ARRAY, /* alreadyExistingRoots */
new QueryableArray(EMPTY_IU_ARRAY), /* installedIUs */
seedUnits, /* newRoots */
monitor);
IStatus s = projector.invokeSolver(monitor);
if (s.getSeverity() == IStatus.ERROR) {
// log all transitive requirements which cannot be satisfied; this doesn't print the dependency chain from the seed to the units with missing requirements, so this is less useful than the "explanation"
logger.debug(StatusTool.collectProblems(s));
// suppress "Cannot complete the request. Generating details."
Set<Explanation> explanation = projector.getExplanation(new NullProgressMonitor());
throw new ResolverException(toString(explanation), newSelectionContext.toString(), StatusTool.findException(s));
}
Collection<IInstallableUnit> newState = projector.extractSolution();
// remove fake IUs from resolved state
newState.removeAll(data.getEEResolutionHints().getTemporaryAdditions());
fixSWT(data.getAvailableIUs(), newState, newSelectionContext, monitor);
if (logger.isExtendedDebugEnabled()) {
logger.debug("Resolved IUs:\n" + ResolverDebugUtils.toDebugString(newState, false));
}
return newState;
}
Aggregations