use of org.eclipse.tycho.repository.p2base.metadata.QueryableCollection in project tycho by eclipse.
the class DependencyCollector method resolve.
@Override
public Collection<IInstallableUnit> resolve(Map<String, String> properties, IProgressMonitor monitor) {
Set<IInstallableUnit> result = new LinkedHashSet<>();
LinkedHashSet<IStatus> errors = new LinkedHashSet<>();
if (logger.isExtendedDebugEnabled()) {
logger.debug("Available IUs:\n" + ResolverDebugUtils.toDebugString(data.getAvailableIUs(), false));
logger.debug("Root IUs:\n" + ResolverDebugUtils.toDebugString(data.getRootIUs(), true));
}
result.addAll(data.getRootIUs());
QueryableCollection availableUIsQueryable = new QueryableCollection(data.getAvailableIUs());
for (IInstallableUnit iu : data.getRootIUs()) {
collectIncludedIUs(availableUIsQueryable, result, errors, iu, true, monitor);
}
if (logger.isExtendedDebugEnabled()) {
logger.debug("Collected IUs:\n" + ResolverDebugUtils.toDebugString(result, false));
}
if (!errors.isEmpty()) {
MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, 0, errors.toArray(new IStatus[errors.size()]), "Missing dependencies", null);
throw new RuntimeException(status.toString(), new ProvisionException(status));
}
return result;
}
use of org.eclipse.tycho.repository.p2base.metadata.QueryableCollection in project tycho by eclipse.
the class ProjectorResolutionStrategy method fixSWT.
/*
* workaround for SWT bug 361901: bundles generally require org.eclipse.swt, but this is an
* empty shell and only native fragments of org.eclipse.swt provide classes to compile against.
* There is no dependency from the host to the fragments, so we need to add the matching SWT
* fragment manually.
*/
void fixSWT(Collection<IInstallableUnit> availableIUs, Collection<IInstallableUnit> resolutionResult, Map<String, String> newSelectionContext, IProgressMonitor monitor) {
IInstallableUnit swtHost = findSWTHostIU(resolutionResult);
if (swtHost == null) {
return;
} else if (swtHost.getVersion().compareTo(Version.createOSGi(3, 104, 0)) >= 0) {
// bug 361901 was fixed in Mars
return;
}
// 380934 one of rootIUs can be SWT or an SWT fragment
for (IInstallableUnit iu : data.getRootIUs()) {
if ("org.eclipse.swt".equals(iu.getId())) {
return;
}
for (IProvidedCapability provided : iu.getProvidedCapabilities()) {
if ("osgi.fragment".equals(provided.getNamespace()) && "org.eclipse.swt".equals(provided.getName())) {
return;
}
}
}
IInstallableUnit swtFragment = null;
all_ius: for (Iterator<IInstallableUnit> iter = new QueryableCollection(availableIUs).query(QueryUtil.ALL_UNITS, monitor).iterator(); iter.hasNext(); ) {
IInstallableUnit iu = iter.next();
if (iu.getId().startsWith("org.eclipse.swt") && isApplicable(newSelectionContext, iu.getFilter()) && providesJavaPackages(iu)) {
for (IProvidedCapability provided : iu.getProvidedCapabilities()) {
if ("osgi.fragment".equals(provided.getNamespace()) && "org.eclipse.swt".equals(provided.getName())) {
if (swtFragment == null || swtFragment.getVersion().compareTo(iu.getVersion()) < 0) {
swtFragment = iu;
}
continue all_ius;
}
}
}
}
if (swtFragment == null) {
throw new RuntimeException("Could not determine SWT implementation fragment bundle for environment " + newSelectionContext);
}
resolutionResult.add(swtFragment);
}
use of org.eclipse.tycho.repository.p2base.metadata.QueryableCollection 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;
}
use of org.eclipse.tycho.repository.p2base.metadata.QueryableCollection in project tycho by eclipse.
the class P2ResolverImpl method resolveInstallableUnit.
// TODO 412416 this should be a method on the class TargetPlatform
@Override
public P2ResolutionResult resolveInstallableUnit(TargetPlatform targetPlatform, String id, String versionRange) {
setContext(targetPlatform, null);
QueryableCollection queriable = new QueryableCollection(context.getInstallableUnits());
VersionRange range = new VersionRange(versionRange);
IRequirement requirement = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, null, 1, /* min */
Integer.MAX_VALUE, /* max */
false);
IQueryResult<IInstallableUnit> result = queriable.query(QueryUtil.createLatestQuery(QueryUtil.createMatchQuery(requirement.getMatches())), monitor);
Set<IInstallableUnit> newState = result.toUnmodifiableSet();
return toResolutionResult(newState, null);
}
Aggregations