diff options
author | Pascal Rapicault | 2011-06-11 21:07:27 +0000 |
---|---|---|
committer | Pascal Rapicault | 2011-06-11 21:07:27 +0000 |
commit | 8cf9ae7017e7d1330787263c433c35fc15084809 (patch) | |
tree | 461d3c543fc7f71a73fa7bb92374a7fb2ad8f71e /bundles | |
parent | 969a3af47af06e8211d8e8a5868d7246033c3368 (diff) | |
download | rt.equinox.p2-8cf9ae7017e7d1330787263c433c35fc15084809.tar.gz rt.equinox.p2-8cf9ae7017e7d1330787263c433c35fc15084809.tar.xz rt.equinox.p2-8cf9ae7017e7d1330787263c433c35fc15084809.zip |
Bug 345726 - [publisher] fully qualified dynamic imports are treated as greedy optional imports
Diffstat (limited to 'bundles')
3 files changed, 21 insertions, 7 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 d03f39920..9d5a40ef8 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 @@ -166,12 +166,11 @@ public class BundlesAction extends AbstractPublisherAction { for (int i = 0; i < osgiImports.length; i++) { // TODO we need to sort out how we want to handle wild-carded dynamic imports - for now we ignore them ImportPackageSpecification importSpec = osgiImports[i]; - String importPackageName = importSpec.getName(); - if (importPackageName.indexOf('*') != -1) + if (isDynamicImport(importSpec)) continue; VersionRange versionRange = PublisherHelper.fromOSGiVersionRange(importSpec.getVersionRange()); //TODO this needs to be refined to take into account all the attribute handled by imports - reqsDeps.add(MetadataFactory.createRequirement(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, importPackageName, versionRange, null, isOptional(importSpec), false)); + reqsDeps.add(MetadataFactory.createRequirement(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, importSpec.getName(), versionRange, null, isOptional(importSpec), false)); } iu.setRequirements(reqsDeps.toArray(new IRequirement[reqsDeps.size()])); @@ -368,10 +367,12 @@ public class BundlesAction extends AbstractPublisherAction { return unconfigScript; } + private static boolean isDynamicImport(ImportPackageSpecification importedPackage) { + return importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC); + } + private static boolean isOptional(ImportPackageSpecification importedPackage) { - if (importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC) || importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_OPTIONAL)) - return true; - return false; + return importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_OPTIONAL); } private static String toManifestString(Map<String, String> p) { 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 d5e351aad..37c996ea5 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 @@ -23,7 +23,8 @@ import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.actions.*; -import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.publisher.eclipse.IBundleShapeAdvice; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; @@ -355,4 +356,9 @@ public class BundlesActionTest extends ActionTest { } + public void testDynamicImport() { + File testData = getTestData("dymamicImport", "testData/dynamicImport"); + IInstallableUnit iu = BundlesAction.createBundleIU(BundlesAction.createBundleDescription(testData), null, new PublisherInfo()); + assertEquals(0, iu.getRequirements().size()); + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/dynamicImport/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/testData/dynamicImport/META-INF/MANIFEST.MF new file mode 100644 index 000000000..5c9b7a5a7 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/dynamicImport/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: TestDynamicImport +Bundle-SymbolicName: TestDynamicImport +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +DynamicImport-Package: org.foo |