Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodor Boev2017-05-30 16:12:40 +0000
committerTodor Boev2017-09-29 10:37:06 +0000
commit872431089780603782ca6de7c774059ed8620e3c (patch)
tree626fd9da24d2d9071237ae48b1a3b3e9271634b3 /bundles/org.eclipse.equinox.p2.publisher.eclipse
parentaa4390e03ef4b5f6676c9e2991779df068b38f2b (diff)
downloadrt.equinox.p2-872431089780603782ca6de7c774059ed8620e3c.tar.gz
rt.equinox.p2-872431089780603782ca6de7c774059ed8620e3c.tar.xz
rt.equinox.p2-872431089780603782ca6de7c774059ed8620e3c.zip
Bug 313553 - Capability: add handling to BundlesActionI20171002-2000
Update BundlesAction to publish the bundle generic capabilities. Fix BundlesActionTest to handle the newly published capabilities. Change-Id: I4b3d11b64706b4fc77b9084f27f8e1583f15580e Signed-off-by: Todor Boev <rinsvind@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
index eaaa780cf..4cf0fc352 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
import org.eclipse.equinox.p2.metadata.*;
@@ -206,11 +207,43 @@ public class BundlesAction extends AbstractPublisherAction {
providedCapabilities.add(MetadataFactory.createProvidedCapability(CAPABILITY_NS_OSGI_BUNDLE, bd.getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
// Process exported packages
- ExportPackageDescription[] exportedPackages = bd.getExportPackages();
- for (ExportPackageDescription packageExport : exportedPackages) {
+ for (ExportPackageDescription packageExport : bd.getExportPackages()) {
providedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageExport.getName(), PublisherHelper.fromOSGiVersion(packageExport.getVersion())));
}
+ // Process generic capabilities
+
+ // TODO
+ // IProvidedCapability may have to be extended to contain the OSGi directives as well which may be needed for
+ // Bug 360659, Bug 525368. E.g. with IProvidedCapability.getDirectives()
+
+ // TODO
+ // The "osgi.wiring.bundle" capability seems equal to p2 "osgi.bundle" capability.
+ // It may be better to derive it at runtime.
+
+ // TODO
+ // It may be possible map the "osgi.identity" capability to elements of the IU like the id, the license, etc.
+ // It may be better to derive it at runtime.
+
+ int numCapName = 0;
+ for (GenericDescription genericCap : bd.getGenericCapabilities()) {
+ String capNs = genericCap.getType();
+
+ Map<String, Object> capAttrs = genericCap.getDeclaredAttributes();
+
+ // Some capabilities do not follow the OSGi convention to have an attribute with a key equal to their namespace (e.g. "osgi.service")
+ // In such cases synthesize a unique name
+ if (!capAttrs.containsKey(capNs)) {
+ capAttrs = new HashMap<>(capAttrs);
+ capAttrs.put(
+ ProvidedCapability.MEMBER_NAME,
+ String.format("%s_%s-%s", iu.getId(), iu.getVersion(), numCapName++)); //$NON-NLS-1$
+ numCapName++;
+ }
+
+ providedCapabilities.add(MetadataFactory.createProvidedCapability(capNs, capAttrs));
+ }
+
// Add capability to describe the type of bundle
if (manifest != null && manifest.containsKey("Eclipse-SourceBundle")) { //$NON-NLS-1$
providedCapabilities.add(SOURCE_BUNDLE_CAPABILITY);

Back to the top