Search in sources :

Example 1 with Slicer

use of org.eclipse.equinox.internal.p2.director.Slicer in project tycho by eclipse.

the class AbstractSlicerResolutionStrategy method slice.

protected final IQueryable<IInstallableUnit> slice(Map<String, String> properties, IProgressMonitor monitor) throws ResolverException {
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Properties: " + properties.toString());
        logger.debug("Available IUs:\n" + toDebugString(data.getAvailableIUs(), false));
        logger.debug("JRE IUs:\n" + toDebugString(data.getEEResolutionHints().getMandatoryUnits(), false));
        logger.debug("Root IUs:\n" + toDebugString(data.getRootIUs(), true));
        if (data.getAdditionalRequirements() != null && !data.getAdditionalRequirements().isEmpty()) {
            StringBuilder sb = new StringBuilder();
            for (IRequirement req : data.getAdditionalRequirements()) {
                sb.append("   ").append(req.toString()).append("\n");
            }
            logger.debug("Extra Requirements:\n" + sb.toString());
        }
    }
    Set<IInstallableUnit> availableIUs = new LinkedHashSet<>(data.getAvailableIUs());
    availableIUs.addAll(data.getEEResolutionHints().getTemporaryAdditions());
    availableIUs.addAll(data.getEEResolutionHints().getMandatoryUnits());
    Set<IInstallableUnit> seedIUs = new LinkedHashSet<>(data.getRootIUs());
    if (data.getAdditionalRequirements() != null && !data.getAdditionalRequirements().isEmpty()) {
        seedIUs.add(createUnitRequiring("tycho-extra", null, data.getAdditionalRequirements()));
    }
    // make sure profile UIs are part of the slice
    seedIUs.addAll(data.getEEResolutionHints().getMandatoryUnits());
    if (!data.getEEResolutionHints().getMandatoryRequires().isEmpty()) {
        seedIUs.add(createUnitRequiring("tycho-ee", null, data.getEEResolutionHints().getMandatoryRequires()));
    }
    Slicer slicer = newSlicer(new QueryableCollection(availableIUs), properties);
    IQueryable<IInstallableUnit> slice = slicer.slice(seedIUs.toArray(EMPTY_IU_ARRAY), monitor);
    MultiStatus slicerStatus = slicer.getStatus();
    if (slice == null || isSlicerError(slicerStatus)) {
        throw new ResolverException(StatusTool.toLogMessage(slicerStatus), properties.toString(), StatusTool.findException(slicerStatus));
    }
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Slice:\n" + ResolverDebugUtils.toDebugString(slice, false, monitor));
    }
    return slice;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) Slicer(org.eclipse.equinox.internal.p2.director.Slicer) QueryableCollection(org.eclipse.tycho.repository.p2base.metadata.QueryableCollection) MultiStatus(org.eclipse.core.runtime.MultiStatus) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Slicer (org.eclipse.equinox.internal.p2.director.Slicer)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)1 QueryableCollection (org.eclipse.tycho.repository.p2base.metadata.QueryableCollection)1