Search in sources :

Example 1 with QueryableArray

use of org.eclipse.equinox.internal.p2.director.QueryableArray 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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) Projector(org.eclipse.equinox.internal.p2.director.Projector) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Explanation(org.eclipse.equinox.internal.p2.director.Explanation) ArrayList(java.util.ArrayList) QueryableArray(org.eclipse.equinox.internal.p2.director.QueryableArray) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Explanation (org.eclipse.equinox.internal.p2.director.Explanation)1 Projector (org.eclipse.equinox.internal.p2.director.Projector)1 QueryableArray (org.eclipse.equinox.internal.p2.director.QueryableArray)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)1