Skip to content

Commit 5cd464d

Browse files
committed
TestSuiteHelper: Include felix.scr if osgi.component is required
Some test cases use 'org.eclipse.core.runtime' as dependency. One of the runtime's dependencies (org.eclipse.core.contenttype) uses declarative services to provide a service component, but was missing the Require-Capability: header to require the osgi.extender=osgi.component. In eclipse-platform/eclipse.platform#2162 this was correct. But as a result, for the resolution of org.eclipse.core.runtime to succeed, a OSGI extender provider must now strictly be present. This cannot be auto-resolved as the PDE API tooling tests, as these tests are quite special and the bundles available in the resolver state are hand-picked by TestSuiteHelper.addAllRequired(IApiBaseline, Set<String>, IApiComponent, List<IApiComponent>) which currently does not support this kind of dependency. To work around that, we check if we find a dependency on SCR and if so, add an implementation for it to the baseline fixture: org.apache.felix.scr and its dependencies.
1 parent 9213517 commit 5cd464d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

  • apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests

apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TestSuiteHelper.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.eclipse.osgi.service.resolver.ResolverError;
3636
import org.eclipse.pde.api.tools.internal.model.ApiModelFactory;
3737
import org.eclipse.pde.api.tools.internal.model.ApiType;
38+
import org.eclipse.pde.api.tools.internal.model.BundleComponent;
3839
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
3940
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
4041
import org.eclipse.pde.api.tools.internal.provisional.IRequiredComponentDescription;
@@ -51,6 +52,8 @@
5152
import org.eclipse.pde.api.tools.internal.util.Util;
5253
import org.junit.Assert;
5354
import org.osgi.framework.Bundle;
55+
import org.osgi.framework.Constants;
56+
import org.osgi.framework.wiring.BundleRequirement;
5457

5558
/**
5659
* Helper methods to set up baselines, etc.
@@ -412,6 +415,30 @@ public static File getBundle(String bundleName) {
412415
*/
413416
public static void addAllRequired(IApiBaseline baseline, Set<String> done, IApiComponent component, List<IApiComponent> collection) throws CoreException {
414417
IRequiredComponentDescription[] descriptions = component.getRequiredComponents();
418+
if (component instanceof BundleComponent bc) {
419+
for (BundleRequirement extenderRequirements : bc.getBundleDescription()
420+
.getDeclaredRequirements("osgi.extender")) { //$NON-NLS-1$
421+
if (extenderRequirements.getDirectives().get(Constants.FILTER_DIRECTIVE)
422+
.matches(".*osgi.extender\\s*=\\s*osgi.component.*")) { //$NON-NLS-1$
423+
if (!done.contains("org.apache.felix.scr")) { //$NON-NLS-1$
424+
List<String> scrAndDependencies = List.of("org.apache.felix.scr", "org.osgi.service.event", //$NON-NLS-1$ //$NON-NLS-2$
425+
"org.osgi.service.component", "org.osgi.util.promise", "org.osgi.util.function"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
426+
for (String scrBundleId : scrAndDependencies) {
427+
File scrBundle = getBundle(scrBundleId);
428+
if (scrBundle != null) {
429+
IApiComponent scrComponent = ApiModelFactory.newApiComponent(baseline,
430+
scrBundle.getAbsolutePath());
431+
if (scrComponent != null) {
432+
collection.add(scrComponent);
433+
done.add(scrComponent.getSymbolicName());
434+
}
435+
}
436+
}
437+
438+
}
439+
}
440+
}
441+
}
415442
boolean error = false;
416443
StringBuilder buffer = null;
417444
for (IRequiredComponentDescription description : descriptions) {

0 commit comments

Comments
 (0)