Skip to content

Commit d007c47

Browse files
authored
Merge branch 'eclipse-pde:master' into add-missing-versions-to-package-exports
2 parents 7ad3e31 + bcbeb9c commit d007c47

File tree

11 files changed

+78
-17
lines changed

11 files changed

+78
-17
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: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,19 @@ public enum Options {
6868
* Specifies to include all non-test fragments into the closure (must
6969
* not be combined with {@link #INCLUDE_ALL_FRAGMENTS}).
7070
*/
71-
INCLUDE_NON_TEST_FRAGMENTS;
71+
INCLUDE_NON_TEST_FRAGMENTS,
72+
/**
73+
* Option that can be set to include native fragments, that are ones
74+
* that define an {@link ICoreConstants#PLATFORM_FILTER} in their
75+
* manifest.
76+
*/
77+
INCLUDE_PLATFORM_FRAGMENTS,
78+
/**
79+
* Option that can be set to include native fragments, that are ones
80+
* that define an {@link ICoreConstants#PLATFORM_FILTER} in their
81+
* manifest.
82+
*/
83+
INCLUDE_EXTENSIBLE_FRAGMENTS;
7284
}
7385

7486
/**
@@ -168,6 +180,8 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
168180
boolean includeOptional = optionSet.contains(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
169181
boolean includeAllFragments = optionSet.contains(Options.INCLUDE_ALL_FRAGMENTS);
170182
boolean includeNonTestFragments = optionSet.contains(Options.INCLUDE_NON_TEST_FRAGMENTS);
183+
boolean includeNativeFragments = optionSet.contains(Options.INCLUDE_PLATFORM_FRAGMENTS);
184+
boolean includeExtensibleFragments = optionSet.contains(Options.INCLUDE_EXTENSIBLE_FRAGMENTS);
171185
if (includeAllFragments && includeNonTestFragments) {
172186
throw new AssertionError("Cannot combine INCLUDE_ALL_FRAGMENTS and INCLUDE_NON_TEST_FRAGMENTS"); //$NON-NLS-1$
173187
}
@@ -188,14 +202,22 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
188202
if (wiring == null || !wiring.isInUse()) {
189203
continue;
190204
}
191-
if (includeAllFragments || includeNonTestFragments || isExtensibleApi(bundle)) {
205+
if (includeAllFragments || includeNonTestFragments
206+
|| (includeExtensibleFragments && isExtensibleApi(bundle))) {
192207
// A fragment's host is already required by a wire
193208
for (BundleDescription fragment : bundle.getFragments()) {
194209
if (includeAllFragments || !isTestWorkspaceProject(fragment)) {
195210
addNewRequiredBundle(fragment, closure, pending);
196211
}
197212
}
198213
}
214+
if (includeNativeFragments) {
215+
for (BundleDescription fragment : bundle.getFragments()) {
216+
if (isNativeFragment(fragment) && !isTestWorkspaceProject(fragment)) {
217+
addNewRequiredBundle(fragment, closure, pending);
218+
}
219+
}
220+
}
199221

200222
if (isFragment(wiring.getRevision())) {
201223
// Requirements of a fragment are hosted at the host, which
@@ -231,6 +253,14 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
231253
return closure;
232254
}
233255

256+
private static boolean isNativeFragment(BundleDescription fragment) {
257+
Object userObject = fragment.getUserObject();
258+
if (userObject instanceof IPluginModelBase model) {
259+
return ClasspathUtilCore.getPlatformFilter(model) != null;
260+
}
261+
return false;
262+
}
263+
234264
private static boolean isExtensibleApi(BundleDescription bundleDescription) {
235265
if (bundleDescription.getFragments().length == 0) {
236266
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+
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
}

ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %name
44
Bundle-SymbolicName: org.eclipse.pde.launching;singleton:=true
5-
Bundle-Version: 3.13.500.qualifier
5+
Bundle-Version: 3.13.600.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-17
77
Bundle-Vendor: %provider-name
88
Require-Bundle: org.eclipse.jdt.junit.core;bundle-version="[3.6.0,4.0.0)",

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,21 @@ private static void addRequiredBundles(Map<IPluginModelBase, String> bundle2star
168168
List<String> appRequirements = RequirementHelper.getApplicationLaunchRequirements(configuration);
169169
RequirementHelper.addApplicationLaunchRequirements(appRequirements, configuration, bundle2startLevel);
170170

171-
boolean includeOptional = configuration.getAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
172-
computeDependencies(bundle2startLevel.keySet(), includeOptional, true) //
171+
Set<DependencyManager.Options> options = configurationToOptions(configuration, true);
172+
computeDependencies(bundle2startLevel.keySet(), options, true) //
173173
.forEach(p -> addDefaultStartingBundle(bundle2startLevel, p));
174174
}
175175

176+
protected static Set<DependencyManager.Options> configurationToOptions(ILaunchConfiguration configuration, boolean optionalDefault) throws CoreException {
177+
boolean includeOptional = configuration.getAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, optionalDefault);
178+
Set<DependencyManager.Options> options = new HashSet<>();
179+
options.add(DependencyManager.Options.INCLUDE_EXTENSIBLE_FRAGMENTS);
180+
if (includeOptional) {
181+
options.add(DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES);
182+
}
183+
return options;
184+
}
185+
176186
// --- feature based launches ---
177187

178188
private static Map<IPluginModelBase, String> getMergedBundleMapFeatureBased(ILaunchConfiguration configuration, Map<IFeature, Boolean> features) throws CoreException {
@@ -221,12 +231,13 @@ private static Map<IPluginModelBase, String> getMergedBundleMapFeatureBased(ILau
221231
launchPlugins.addAll(additionalPlugins.keySet());
222232

223233
if (addRequirements) {
234+
Set<DependencyManager.Options> options = configurationToOptions(configuration, false);
224235
// Add all missing plug-ins required by the application/product set in the config
225236
List<String> appRequirements = RequirementHelper.getApplicationLaunchRequirements(configuration);
226237
RequirementHelper.addApplicationLaunchRequirements(appRequirements, configuration, launchPlugins, launchPlugins::add);
227238

228239
// Get all required plugins
229-
computeDependencies(launchPlugins, false, isWorkspace(defaultPluginResolution)).forEach(launchPlugins::add);
240+
computeDependencies(launchPlugins, options, isWorkspace(defaultPluginResolution)).forEach(launchPlugins::add);
230241
}
231242

232243
// Create the start levels for the selected plugins and add them to the map
@@ -542,7 +553,7 @@ private static void addBundleToMap(Map<IPluginModelBase, String> map, IPluginMod
542553

543554
// --- dependency resolution ---
544555

545-
private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase> includedPlugins, boolean includeOptional, boolean preferWorkspaceBundles) {
556+
private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase> includedPlugins, Set<DependencyManager.Options> options, boolean preferWorkspaceBundles) {
546557
if (includedPlugins.isEmpty()) {
547558
return Stream.empty();
548559
}
@@ -556,11 +567,7 @@ private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase
556567
Version version = versionStr != null ? Version.parseVersion(versionStr) : null;
557568
return launchState.getBundle(descriptor.getId(), version);
558569
}).forEach(launchBundles::add);
559-
560-
DependencyManager.Options[] options = includeOptional //
561-
? new DependencyManager.Options[] {DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES}
562-
: new DependencyManager.Options[] {};
563-
Set<BundleDescription> closure = DependencyManager.findRequirementsClosure(launchBundles, options);
570+
Set<BundleDescription> closure = DependencyManager.findRequirementsClosure(launchBundles, options.toArray(DependencyManager.Options[]::new));
564571
return closure.stream().map(launchBundlePlugins::get).map(Objects::requireNonNull) //
565572
.filter(p -> !includedPlugins.contains(p));
566573
}

ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: PDE JUnit Tests
44
Bundle-SymbolicName: org.eclipse.pde.ui.tests; singleton:=true
5-
Bundle-Version: 3.13.200.qualifier
5+
Bundle-Version: 3.13.300.qualifier
66
Bundle-ClassPath: tests.jar
77
Bundle-Vendor: Eclipse.org
88
Require-Bundle: org.eclipse.pde.ui,

ui/org.eclipse.pde.ui.tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<relativePath>../../</relativePath>
1919
</parent>
2020
<artifactId>org.eclipse.pde.ui.tests</artifactId>
21-
<version>3.13.200-SNAPSHOT</version>
21+
<version>3.13.300-SNAPSHOT</version>
2222
<packaging>eclipse-test-plugin</packaging>
2323

2424
<properties>

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/FeatureBasedLaunchTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,8 @@ public void testGetMergedBundleMap_automaticallyAddRequirements() throws Throwab
13511351
}));
13521352

13531353
// Gather requirements of the product used below
1354-
Map<BundleLocationDescriptor, String> requiredRPBundles = getEclipseAppRequirementClosureForRunningPlatform();
1354+
Map<BundleLocationDescriptor, String> requiredRPBundles = getEclipseAppRequirementClosureForRunningPlatform(
1355+
DependencyManager.Options.INCLUDE_EXTENSIBLE_FRAGMENTS);
13551356

13561357
TargetPlatformUtil.setRunningPlatformWithDummyBundlesAsTarget(null, targetBundles, targetFeatures,
13571358
tpJarDirectory);

0 commit comments

Comments
 (0)