Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodor Boev2017-05-30 12:12:40 -0400
committerTodor Boev2017-09-29 06:37:06 -0400
commit872431089780603782ca6de7c774059ed8620e3c (patch)
tree626fd9da24d2d9071237ae48b1a3b3e9271634b3 /bundles
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')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java7
4 files changed, 44 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
index be7aea670..2c68d5ecc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
@@ -93,7 +93,9 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider
}
public String getName() {
- return (String) attributes.get(MEMBER_NAME);
+ // There is always a "name" member, but it may not always be a string.
+ // Convert it here so that it is still possible to get the real type via getAttributes().
+ return attributes.get(MEMBER_NAME).toString();
}
public String getNamespace() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java
index e895d5bc2..47aa3ee51 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java
@@ -31,7 +31,7 @@ public interface IProvidedCapability {
/**
*
- * @return String the special "name" attribute of this capability.
+ * @return String the String representation of the special "name" attribute of this capability.
* @noreference This method is not intended to be referenced by clients.
*/
public String getName();
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);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
index dd53c2aee..75eef92d0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
@@ -40,6 +40,7 @@ import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
public class BundlesActionTest extends ActionTest {
private static final String OSGI = PublisherHelper.OSGI_BUNDLE_CLASSIFIER;
+ private static final String OSGI_IDENTITY = "osgi.identity";
private static final String JAVA_PACKAGE = "java.package";//$NON-NLS-1$
private static final String JAVA_EE_1_4_REQ = "providedCapabilities.exists(pc | pc ~= filter('(&(namespace=osgi.ee)(|(&(osgi.ee=JavaSE)(version=1.4))(&(osgi.ee=CDC/Foundation)(version=1.1))))'))";
private static final String JAVA_EE_1_6_REQ = "providedCapabilities.exists(pc | pc ~= filter('(&(namespace=osgi.ee)(&(osgi.ee=JavaSE)(version=1.6)))'))";
@@ -223,10 +224,11 @@ public class BundlesActionTest extends ActionTest {
// check provided capabilities
Collection<IProvidedCapability> providedCapabilities = bundle1IU.getProvidedCapabilities();
verifyProvidedCapability(providedCapabilities, PROVBUNDLE_NAMESPACE, TEST1_PROVBUNDLE_NAME, BUNDLE1_VERSION);
+ verifyProvidedCapability(providedCapabilities, OSGI_IDENTITY, TEST1_PROVBUNDLE_NAME, BUNDLE1_VERSION);
verifyProvidedCapability(providedCapabilities, OSGI, TEST1_PROVBUNDLE_NAME, BUNDLE1_VERSION);
verifyProvidedCapability(providedCapabilities, TEST1_PROV_Z_NAMESPACE, TEST1_PROVZ_NAME, TEST2_PROVZ_VERSION);
verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "source", Version.create("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$
- assertEquals("2.1", 4, providedCapabilities.size());
+ assertEquals("2.1", 5, providedCapabilities.size());
Collection<ITouchpointData> data = bundle1IU.getTouchpointData();
boolean found = false;
@@ -262,11 +264,12 @@ public class BundlesActionTest extends ActionTest {
Collection<IProvidedCapability> providedCapabilities = bundle2IU.getProvidedCapabilities();
verifyProvidedCapability(providedCapabilities, PROVBUNDLE_NAMESPACE, TEST2_PROV_BUNDLE_NAME, PROVBUNDLE2_VERSION);
verifyProvidedCapability(providedCapabilities, OSGI, TEST2_PROV_BUNDLE_NAME, BUNDLE2_VERSION);
+ verifyProvidedCapability(providedCapabilities, OSGI_IDENTITY, TEST2_PROV_BUNDLE_NAME, BUNDLE2_VERSION);
verifyProvidedCapability(providedCapabilities, TEST2_PROV_Z_NAMESPACE, TEST2_PROV_Z_NAME, TEST2_PROVZ_VERSION);
verifyProvidedCapability(providedCapabilities, TEST2_PROV_Y_NAMESPACE, TEST2_PROV_Y_NAME, TEST2_PROVY_VERSION);
verifyProvidedCapability(providedCapabilities, TEST2_PROV_X_NAMESPACE, TEST2_PROV_X_NAME, TEST2_PROVX_VERSION);
verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "bundle", Version.create("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$
- assertEquals(6, providedCapabilities.size()); /*number of tested elements*/
+ assertEquals(7, providedCapabilities.size()); /*number of tested elements*/
// check %bundle name is correct
Map<String, String> prop = bundle2IU.getProperties();

Back to the top