use of org.eclipse.equinox.p2.metadata.IInstallableUnit 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.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method setupCatalog.
protected void setupCatalog() throws MalformedURLException {
final SearchResult discoveryResult = new SearchResult();
discoveryResult.setNodes(discoveryNodes);
CatalogDescriptor catalogDescriptor = new CatalogDescriptor();
catalogDescriptor.setUrl(new URL("http://marketplace.eclipse.org"));
MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
final MarketplaceCategory category = new MarketplaceCategory();
{
category.setId("<root>");
}
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (!categories.contains(category)) {
categories.add(category);
}
handleSearchResult(category, discoveryResult, new NullProgressMonitor());
}
@Override
protected synchronized Map<String, IInstallableUnit> computeInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
for (INode node : installedNodes) {
IIus ius = node.getIus();
if (ius != null) {
for (IIu iu : ius.getIuElements()) {
String featureId = iu.getId() + ".feature.group";
InstallableUnit installableUnit = new InstallableUnit();
installableUnit.setId(featureId);
installedIus.put(featureId, installableUnit);
}
}
}
return installedIus;
}
@Override
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
return category;
}
};
catalog = new MarketplaceCatalog() {
@Override
protected IStatus checkForUpdates(List<MarketplaceNodeCatalogItem> updateCheckNeeded, final Map<String, IInstallableUnit> installedIUs, final IProgressMonitor monitor) {
for (MarketplaceNodeCatalogItem item : updateCheckNeeded) {
checkedForUpdate.add(item.getData());
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
boolean hasUpdate = updateAvailable.contains(item.getData());
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
iuItem.setUpdateAvailable(hasUpdate);
}
}
return Status.OK_STATUS;
}
};
catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceWizard method computeNewInstallCatalogItems.
private Set<CatalogItem> computeNewInstallCatalogItems() {
Set<CatalogItem> items = new HashSet<CatalogItem>();
Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
List<FeatureEntry> features = entry.getChildren();
Collection<String> featureIds = new ArrayList<String>(features.size());
for (FeatureEntry feature : features) {
if (feature.computeChangeOperation() == Operation.INSTALL) {
featureIds.add(feature.getFeatureDescriptor().getId());
}
}
if (!featureIds.isEmpty()) {
iusByCatalogItem.put(entry.getItem(), featureIds);
}
}
for (IInstallableUnit unit : operationIUs) {
for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
if (entry.getValue().contains(unit.getId())) {
items.add(entry.getKey());
}
}
}
return items;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method computeInstalled.
protected SearchResult computeInstalled(IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
result.setNodes(new ArrayList<Node>());
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_ComputingInstalled, 1000);
Map<String, IInstallableUnit> installedIUs = computeInstalledIUs(progress.newChild(500));
if (!monitor.isCanceled()) {
Set<INode> catalogNodes = marketplaceInfo.computeInstalledNodes(catalogDescriptor.getUrl(), installedIUs);
if (!catalogNodes.isEmpty()) {
List<INode> resolvedNodes = marketplaceService.getNodes(catalogNodes, progress.newChild(490));
SubMonitor nodeProgress = SubMonitor.convert(progress.newChild(10), resolvedNodes.size());
for (INode node : resolvedNodes) {
// compute real installed state based on optional/required state
if (marketplaceInfo.computeInstalled(installedIUs.keySet(), node)) {
result.getNodes().add((Node) node);
}
nodeProgress.worked(1);
}
} else {
monitor.worked(500);
}
}
return result;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method pruneOlderVersions.
/**
* Remove ius from the given list where the current profile already contains a newer version of that iu.
*
* @param installableUnits
* @throws CoreException
*/
private void pruneOlderVersions(List<IInstallableUnit> installableUnits) throws CoreException {
if (!installableUnits.isEmpty()) {
Map<String, IInstallableUnit> iUsById = MarketplaceClientUi.computeInstalledIUsById(new NullProgressMonitor());
Iterator<IInstallableUnit> it = installableUnits.iterator();
while (it.hasNext()) {
IInstallableUnit iu = it.next();
IInstallableUnit installedIu = iUsById.get(iu.getId());
if (installedIu != null) {
Version installedVersion = installedIu.getVersion();
Version installableVersion = iu.getVersion();
if (installedVersion.compareTo(installableVersion) >= 0) {
it.remove();
}
}
}
if (installableUnits.isEmpty()) {
throw new CoreException(new Status(IStatus.INFO, MarketplaceClientUi.BUNDLE_ID, Messages.ProvisioningOperation_nothingToUpdate));
}
}
}
Aggregations