Skip to content

Commit

Permalink
The target resolvement should never invalidate
Browse files Browse the repository at this point in the history
It should later fail when the feature or plugin is actual build
so we have more information
  • Loading branch information
jcompagner committed Nov 29, 2021
1 parent a4b5add commit f5f5ae3
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.tycho.p2.util.resolution;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -46,13 +47,26 @@
@SuppressWarnings("restriction")
public class ProjectorResolutionStrategy extends AbstractSlicerResolutionStrategy {

private final class CustomSlider extends Slicer {
private CustomSlider(IQueryable<IInstallableUnit> input, Map<String, String> context,
boolean considerMetaRequirements) {
super(input, context, considerMetaRequirements);
}

@Override
public IQueryable<IInstallableUnit> slice(IInstallableUnit[] ius, IProgressMonitor monitor) {
return super.slice(Arrays.asList(ius).stream().filter(iu -> isApplicable(iu)).collect(Collectors.toList())
.toArray(new InstallableUnit[0]), monitor);
}
}

public ProjectorResolutionStrategy(MavenLogger logger) {
super(logger);
}

@Override
protected Slicer newSlicer(IQueryable<IInstallableUnit> availableUnits, Map<String, String> properties) {
return new Slicer(availableUnits, properties, false);
return new CustomSlider(availableUnits, properties, false);
}

@Override
Expand Down Expand Up @@ -80,8 +94,8 @@ public Collection<IInstallableUnit> resolve(Map<String, String> properties, IPro

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);
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"
Expand Down Expand Up @@ -136,13 +150,14 @@ void fixSWT(Collection<IInstallableUnit> availableIUs, Collection<IInstallableUn

IInstallableUnit swtFragment = null;

all_ius: for (Iterator<IInstallableUnit> iter = new QueryableCollection(availableIUs).query(
QueryUtil.ALL_UNITS, monitor).iterator(); iter.hasNext();) {
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 ("osgi.fragment".equals(provided.getNamespace())
&& "org.eclipse.swt".equals(provided.getName())) {
if (swtFragment == null || swtFragment.getVersion().compareTo(iu.getVersion()) < 0) {
swtFragment = iu;
}
Expand All @@ -153,8 +168,8 @@ && providesJavaPackages(iu)) {
}

if (swtFragment == null) {
throw new RuntimeException("Could not determine SWT implementation fragment bundle for environment "
+ newSelectionContext);
throw new RuntimeException(
"Could not determine SWT implementation fragment bundle for environment " + newSelectionContext);
}

resolutionResult.add(swtFragment);
Expand Down

0 comments on commit f5f5ae3

Please sign in to comment.