Skip to content

Commit 1b4ca76

Browse files
juergen-albertpkriens
authored andcommitted
Removes Require-Capability for osgi.service AnyService
fixes #5750 Signed-off-by: Juergen Albert <[email protected]> --- Signed-off-by: Peter Kriens <[email protected]>
1 parent d185ade commit 1b4ca76

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

biz.aQute.bndlib.tests/test/test/component/DSAnnotationTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4395,7 +4395,6 @@ public void anyservice() throws Exception {
43954395
assertOk(b);
43964396
Attributes a = getAttr(jar);
43974397
checkProvides(a);
4398-
checkRequires(a, ComponentConstants.COMPONENT_SPECIFICATION_VERSION, AnyService.class.getName());
43994398

44004399
//
44014400
// Test all the defaults
@@ -4444,6 +4443,25 @@ public void anyservice() throws Exception {
44444443
}
44454444
}
44464445

4446+
@Test
4447+
public void anyserviceNoServiceRequirement() throws Exception {
4448+
try (Builder b = new Builder()) {
4449+
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest$AnyServiceUse");
4450+
b.setProperty("Private-Package", "test.component");
4451+
b.addClasspath(new File("bin_test"));
4452+
4453+
Jar jar = b.build();
4454+
assertOk(b);
4455+
Attributes a = getAttr(jar);
4456+
checkProvides(a);
4457+
4458+
jar.getManifest()
4459+
.write(System.out);
4460+
4461+
assertThat(a.getValue(Constants.REQUIRE_CAPABILITY)).doesNotContain(AnyService.class.getName());
4462+
}
4463+
}
4464+
44474465
@Component
44484466
public static class AnyServiceUseNoObject {
44494467
@Activate

biz.aQute.bndlib/src/aQute/bnd/component/DSAnnotations.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ private void addServiceCapability(ComponentDef definition, Set<String> provides,
318318

319319
private void addServiceRequirement(ReferenceDef ref, MergedRequirement requires) {
320320
String objectClass = ref.service;
321+
if ("org.osgi.service.component.AnyService".equals(objectClass)) {
322+
return;
323+
}
321324
ReferenceCardinality cardinality = ref.cardinality;
322325
boolean optional = cardinality == ReferenceCardinality.OPTIONAL || cardinality == ReferenceCardinality.MULTIPLE;
323326
boolean multiple = cardinality == ReferenceCardinality.MULTIPLE

0 commit comments

Comments
 (0)