Skip to content

Commit 282c010

Browse files
committed
Use BuildDependencyCollector
1 parent 0251a18 commit 282c010

3 files changed

Lines changed: 13 additions & 30 deletions

File tree

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,25 @@ private BuildDependencyCollector(Collection<BundleDescription> roots) {
3939
* {@code roots}, including {@code roots} themselves.
4040
*/
4141
public static Collection<BundleDescription> collectBuildRelevantDependencies(Collection<BundleDescription> roots) {
42+
return collectBuildRelevantDependencies(roots, true);
43+
}
44+
45+
static Collection<BundleDescription> collectBuildRelevantDependencies(Collection<BundleDescription> roots,
46+
boolean includeFragmentsHost) {
4247
BuildDependencyCollector collector = new BuildDependencyCollector(roots);
43-
collector.collect();
48+
collector.collect(includeFragmentsHost);
4449
return collector.fDependencies;
4550
}
4651

47-
private void collect() {
52+
private void collect(boolean includeFragmentsHost) {
4853
while (!fQueue.isEmpty()) {
4954
BundleDescription bundleDescription = fQueue.remove();
5055

5156
collectRequiredBundles(bundleDescription);
5257
collectImportedPackages(bundleDescription);
53-
collectFragmentHost(bundleDescription);
58+
if (includeFragmentsHost) {
59+
collectFragmentHost(bundleDescription);
60+
}
5461
}
5562
}
5663

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@
3636
import org.osgi.framework.Bundle;
3737
import org.osgi.framework.Constants;
3838
import org.osgi.framework.Version;
39-
import org.osgi.framework.namespace.BundleNamespace;
40-
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
4139
import org.osgi.framework.namespace.HostNamespace;
42-
import org.osgi.framework.namespace.PackageNamespace;
43-
import org.osgi.framework.wiring.BundleCapability;
4440
import org.osgi.framework.wiring.BundleRequirement;
4541
import org.osgi.framework.wiring.BundleRevision;
4642
import org.osgi.framework.wiring.BundleWire;
@@ -84,12 +80,7 @@ public enum Options {
8480
* that define an {@link ICoreConstants#PLATFORM_FILTER} in their
8581
* manifest.
8682
*/
87-
INCLUDE_EXTENSIBLE_FRAGMENTS,
88-
/**
89-
* Option that can be set to exclude generic capabilities on which the
90-
* bundle depends.
91-
*/
92-
EXCLUDE_REQUIRED_CAPABILITY;
83+
INCLUDE_EXTENSIBLE_FRAGMENTS;
9384
}
9485

9586
/**
@@ -186,7 +177,6 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
186177
Options... options) {
187178

188179
Set<Options> optionSet = Set.of(options);
189-
boolean excludeGenericRequiredCapability = optionSet.contains(Options.EXCLUDE_REQUIRED_CAPABILITY);
190180
boolean includeOptional = optionSet.contains(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
191181
boolean includeAllFragments = optionSet.contains(Options.INCLUDE_ALL_FRAGMENTS);
192182
boolean includeNonTestFragments = optionSet.contains(Options.INCLUDE_NON_TEST_FRAGMENTS);
@@ -252,19 +242,7 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
252242
// not included into the closure.
253243
continue;
254244
}
255-
BundleCapability capability = wire.getCapability();
256-
if (excludeGenericRequiredCapability) {
257-
String namespace = capability.getNamespace();
258-
if (!BundleNamespace.BUNDLE_NAMESPACE.equals(namespace)
259-
&& !PackageNamespace.PACKAGE_NAMESPACE.equals(namespace)
260-
&& !HostNamespace.HOST_NAMESPACE.equals(namespace)
261-
&& !ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(namespace)) {
262-
// If it is not one of the framework namespaces it is a
263-
// generic one see https://docs.osgi.org/specification/osgi.core/8.0.0/framework.namespaces.html
264-
continue;
265-
}
266-
}
267-
BundleRevision provider = capability.getRevision();
245+
BundleRevision provider = wire.getCapability().getRevision();
268246
// Use revision of required capability to support the case if
269247
// fragments contribute new packages to their host's API.
270248
if (provider instanceof BundleDescription requiredBundle && (includeOptional || !isOptional(wire.getRequirement()))) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*******************************************************************************/
1515
package org.eclipse.pde.internal.core;
1616

17-
import static org.eclipse.pde.internal.core.DependencyManager.Options.EXCLUDE_REQUIRED_CAPABILITY;
1817
import static org.eclipse.pde.internal.core.DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES;
1918

2019
import java.io.File;
@@ -684,8 +683,7 @@ private void addImplicitDependencies(BundleDescription desc, Set<BundleDescripti
684683
*/
685684
private void addTransitiveDependenciesWithForbiddenAccess(Set<BundleDescription> added,
686685
List<IClasspathEntry> entries) throws CoreException {
687-
Set<BundleDescription> closure = DependencyManager.findRequirementsClosure(added,
688-
INCLUDE_OPTIONAL_DEPENDENCIES, EXCLUDE_REQUIRED_CAPABILITY);
686+
Collection<BundleDescription> closure = BuildDependencyCollector.collectBuildRelevantDependencies(added);
689687
String systemBundleBSN = TargetPlatformHelper.getPDEState().getSystemBundle();
690688
Iterator<BundleDescription> transitiveDeps = closure.stream()
691689
.filter(desc -> !desc.getSymbolicName().equals(systemBundleBSN))

0 commit comments

Comments
 (0)