diff --git a/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF index b11dda30a0..7fbad0b9c6 100644 --- a/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF +++ b/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.api.tools;singleton:=true -Bundle-Version: 1.3.500.qualifier +Bundle-Version: 1.3.600.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java index 30363ae5c2..afe8204223 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java @@ -82,6 +82,7 @@ import org.osgi.framework.Constants; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; +import org.osgi.framework.namespace.ExecutionEnvironmentNamespace; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -92,6 +93,8 @@ */ public class BundleComponent extends Component { + private static final String[] NO_EXECUTION_ENVIRONMENTS = new String[0]; + static final String TMP_API_FILE_PREFIX = "api"; //$NON-NLS-1$ /** @@ -310,7 +313,12 @@ protected void init() throws CoreException { BundleDescription bundleDescription = getBundleDescription(manifest, fLocation, fBundleId); fSymbolicName = bundleDescription.getSymbolicName(); fVersion = bundleDescription.getVersion(); - fdeclaredRequiredEE = ManifestUtils.getRequiredExecutionEnvironments(bundleDescription).toArray(String[]::new); + if (hasDeclaredRequiredEE(manifest)) { + fdeclaredRequiredEE = ManifestUtils.getRequiredExecutionEnvironments(bundleDescription) + .toArray(String[]::new); + } else { + fdeclaredRequiredEE = NO_EXECUTION_ENVIRONMENTS; + } setName(manifest.get(Constants.BUNDLE_NAME)); fBundleDescription = bundleDescription; } catch (BundleException e) { @@ -1204,4 +1212,28 @@ protected void baselineDisposed(IApiBaseline baseline) throws CoreException { new Object[] { getName(), baseline.getName(), Thread.currentThread().getName() }), disposeSource)); } + + /* + * This is a copy of + * org.eclipse.pde.internal.core.MinimalState.hasDeclaredRequiredEE(Map). PDE ends up adding a synthetic EE to the manifest when that method + * returns false, and that ends up in the bundle description such that we cannot + * determine whether the EE was actually present or was synthesized. So we + * repeat that computation here + */ + @SuppressWarnings("deprecation") + private boolean hasDeclaredRequiredEE(Map manifest) { + if (manifest.containsKey(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)) { + return true; + } + try { + String capability = manifest.get(Constants.REQUIRE_CAPABILITY); + ManifestElement[] header = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, capability); + return header != null && Arrays.stream(header).map(ManifestElement::getValue) + .anyMatch(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE::equals); + } catch (BundleException e) { + return false; // ignore + } + } + }