Skip to content

Commit

Permalink
Consider other locations when resolving IUs from updatesites
Browse files Browse the repository at this point in the history
Currently the IULocation can only consider units from other locations if
these are also of type IU location but other target types might be able
to supply items in a way not know to the IULocation.

This adds the necessary infrastructure to support this usecase by using
the adapter pattern.

Fix #207
  • Loading branch information
laeubi committed Oct 8, 2023
1 parent bcf2c51 commit bcedeb8
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
Expand All @@ -59,6 +61,7 @@
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnitQueryable;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
Expand Down Expand Up @@ -1084,6 +1087,7 @@ private void resolveWithPlanner(ITargetDefinition target, IProgressMonitor monit
context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, Boolean.toString(true));
context.setMetadataRepositories(getMetadataRepositories(target));
context.setArtifactRepositories(getArtifactRepositories(target));
context.setExtraInstallableUnits(getAdditionalProvisionIUs(target));

IProvisioningPlan plan = planner.getProvisioningPlan(request, context, subMonitor.split(20));
IStatus status = plan.getStatus();
Expand Down Expand Up @@ -1547,6 +1551,24 @@ private URI[] getMetadataRepositories(ITargetDefinition target) throws CoreExcep
return result.toArray(new URI[result.size()]);
}

private List<IInstallableUnit> getAdditionalProvisionIUs(ITargetDefinition target) {
List<IInstallableUnit> result = new ArrayList<>();
ITargetLocation[] containers = target.getTargetLocations();
if (containers != null) {
for (ITargetLocation container : containers) {
if (container instanceof IUBundleContainer) {
// this is already handled by getMetadataRepositories(..)
continue;
}
IInstallableUnitQueryable queryable = Adapters.adapt(container, IInstallableUnitQueryable.class);
if (queryable != null) {
queryable.query(QueryUtil.ALL_UNITS, new NullProgressMonitor()).forEach(result::add);
}
}
}
return result;
}

private static final String NATIVE_ARTIFACTS = "nativeArtifacts"; //$NON-NLS-1$
private static final String NATIVE_TYPE = "org.eclipse.equinox.p2.native"; //$NON-NLS-1$
private static final String PARM_OPERAND = "operand"; //$NON-NLS-1$
Expand Down

0 comments on commit bcedeb8

Please sign in to comment.