Skip to content

Commit 3a4eaad

Browse files
committed
Always consider fragments that specify a platform filter
A fragment can declare a Eclipse-PlatformFilter to be only installed on a given platform. If such fragment is currently wired to a host bundle, it is quite likely that fragment is needed but the host usually do not declare an Eclipse-ExtensibleAPI so we currently miss to add such fragment making the native code loading fails. This now adds some code to store the platform filter and if one is given the fragment is always included. Fix #1929
1 parent d9ad053 commit 3a4eaad

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ public static boolean hasExtensibleAPI(IPluginModelBase model) {
224224
return false;
225225
}
226226

227+
public static String getPlatformFilter(IPluginModelBase model) {
228+
IPluginBase pluginBase = model.getPluginBase();
229+
if (pluginBase instanceof BundlePlugin plugin) {
230+
return plugin.getPlatformFilter();
231+
}
232+
if (pluginBase instanceof BundleFragment fragment) {
233+
return fragment.getPlatformFilter();
234+
}
235+
return null;
236+
}
237+
227238
public static boolean isPatchFragment(Resource desc) {
228239
IPluginModelBase model = PluginRegistry.findModel(desc);
229240
return model instanceof IFragmentModel i ? isPatchFragment(i.getFragment()) : false;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
195195
addNewRequiredBundle(fragment, closure, pending);
196196
}
197197
}
198+
} else {
199+
for (BundleDescription fragment : bundle.getFragments()) {
200+
if (isNativeFragment(fragment) && !isTestWorkspaceProject(fragment)) {
201+
addNewRequiredBundle(fragment, closure, pending);
202+
}
203+
}
198204
}
199205

200206
if (isFragment(wiring.getRevision())) {
@@ -231,6 +237,14 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
231237
return closure;
232238
}
233239

240+
private static boolean isNativeFragment(BundleDescription fragment) {
241+
Object userObject = fragment.getUserObject();
242+
if (userObject instanceof IPluginModelBase model) {
243+
return ClasspathUtilCore.getPlatformFilter(model) != null;
244+
}
245+
return false;
246+
}
247+
234248
private static boolean isExtensibleApi(BundleDescription bundleDescription) {
235249
if (bundleDescription.getFragments().length == 0) {
236250
return false;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static class PluginInfo {
9797
String localization;
9898
String bundleSourceEntry;
9999
boolean exportsExternalAnnotations;
100+
public String platformFilter;
100101
}
101102

102103
/**
@@ -379,6 +380,7 @@ protected void addAuxiliaryData(BundleDescription desc, Map<String, String> mani
379380
info.libraries = getClasspath(manifest);
380381
info.hasExtensibleAPI = "true".equals(manifest.get(ICoreConstants.EXTENSIBLE_API)); //$NON-NLS-1$
381382
info.isPatchFragment = "true".equals(manifest.get(ICoreConstants.PATCH_FRAGMENT)); //$NON-NLS-1$
383+
info.platformFilter = manifest.get(ICoreConstants.PLATFORM_FILTER);
382384
info.localization = manifest.get(Constants.BUNDLE_LOCALIZATION);
383385
info.hasBundleStructure = hasBundleStructure;
384386
info.bundleSourceEntry = manifest.get(ICoreConstants.ECLIPSE_SOURCE_BUNDLE);

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundleFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,8 @@ public boolean isPatch() {
122122
return "true".equals(getValue(ICoreConstants.PATCH_FRAGMENT, false)); //$NON-NLS-1$
123123
}
124124

125+
public String getPlatformFilter() {
126+
return getValue(ICoreConstants.PLATFORM_FILTER, false);
127+
}
128+
125129
}

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ public boolean exportsExternalAnnotations() {
5757
return "true".equals(getValue(ICoreConstants.ECLIPSE_EXPORT_EXTERNAL_ANNOTATIONS, false)); //$NON-NLS-1$
5858
}
5959

60+
public String getPlatformFilter() {
61+
return getValue(ICoreConstants.PLATFORM_FILTER, false);
62+
}
63+
6064
}

0 commit comments

Comments
 (0)