Skip to content

Commit 0cfe77d

Browse files
committed
Include fragments when computing dependencies for Extensible-API bundles
Currently there is an option to either include all fragments, or only non-test fragments. But there is some kind of special bundles (like SWT) that declare a custom 'Eclipse-ExtensibleAPI' header, these are handled special in the way that PDE attaches their fragments to the classpath of projects requiring these. This behavior is currently not reflected when computing required dependencies leading to ClassNotFoundException when launching them. This now adds another check, that if such special bundle is found its fragments are considered when it is not a test bundle project.
1 parent f6d83fd commit 0cfe77d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DependencyManager.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.pde.core.plugin.PluginRegistry;
3434
import org.eclipse.pde.core.target.ITargetPlatformService;
3535
import org.eclipse.pde.core.target.NameVersionDescriptor;
36+
import org.osgi.framework.Bundle;
3637
import org.osgi.framework.Constants;
3738
import org.osgi.framework.Version;
3839
import org.osgi.framework.namespace.HostNamespace;
@@ -187,8 +188,7 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
187188
if (wiring == null || !wiring.isInUse()) {
188189
continue;
189190
}
190-
191-
if (includeAllFragments || includeNonTestFragments) {
191+
if (includeAllFragments || includeNonTestFragments || isExtensibleApi(bundle)) {
192192
// A fragment's host is already required by a wire
193193
for (BundleDescription fragment : bundle.getFragments()) {
194194
if (includeAllFragments || !isTestWorkspaceProject(fragment)) {
@@ -229,6 +229,25 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
229229
return closure;
230230
}
231231

232+
private static boolean isExtensibleApi(BundleDescription bundleDescription) {
233+
if (bundleDescription.getFragments().length == 0) {
234+
return false;
235+
}
236+
Object userObject = bundleDescription.getUserObject();
237+
if (userObject instanceof IPluginModelBase model) {
238+
return ClasspathUtilCore.hasExtensibleAPI(model);
239+
}
240+
IPluginModelBase model = PluginRegistry.findModel((Resource) bundleDescription);
241+
if (model != null) {
242+
return ClasspathUtilCore.hasExtensibleAPI(model);
243+
}
244+
Bundle bundle = bundleDescription.getBundle();
245+
if (bundle != null) {
246+
return Boolean.parseBoolean(bundle.getHeaders().get(ICoreConstants.EXTENSIBLE_API));
247+
}
248+
return false;
249+
}
250+
232251
private static void addNewRequiredBundle(BundleDescription bundle, Set<BundleDescription> requiredBundles,
233252
Queue<BundleDescription> pending) {
234253
if (bundle != null && bundle.isResolved() && !bundle.isRemovalPending() && requiredBundles.add(bundle)) {

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ private static void addPluginBundle(IPluginModelBase plugin, State launchState,
602602
throw new IllegalStateException("Plugins have different TP state"); //$NON-NLS-1$
603603
}
604604
BundleDescription launchBundle = launchState.getFactory().createBundleDescription(bundle);
605+
launchBundle.setUserObject(plugin);
605606
if (!launchState.addBundle(launchBundle)) {
606607
throw new IllegalStateException("Failed to add bundle to launch state: " + launchBundle); //$NON-NLS-1$
607608
}

0 commit comments

Comments
 (0)