Drop unconditional osgi.cdi extender requirement from OSGi manifests - #160
Merged
Conversation
The bnd -cdiannotations directive was set to '*' during the Jakarta migration, which makes bnd's CDIAnnotations plugin scan every class and unconditionally add a mandatory 'Require-Capability: osgi.extender; ...osgi.cdi' to the generated manifest of every bnd-processed module, including swagger-jakarta-rest. Because the requirement is mandatory, any non-CDI OSGi runtime that drives the OpenAPI Reader programmatically (e.g. via Declarative Services) fails to resolve the bundle, even though CDI is never used. Revert -cdiannotations to the empty value used upstream so no CDI extender requirement is generated. Runtime CDI autodiscovery is driven by META-INF/beans.xml + the CDI PortableExtension and is unaffected; CDIAutodiscoveryTest still passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
swagger-jakarta-rest(all 4.x releases) carries a mandatoryRequire-Capability: osgi.extender;osgi.cdi;...header in its OSGi manifest:osgi.cdiis the extender of the OSGi CDI Integration spec (Compendium R7 ch. 152), implemented by Apache Aries CDI. Because the requirement is mandatory, every consumer must supply a CDI extender — including runtimes that use Declarative Services and drive the OpenAPI Reader programmatically, where no CDI container exists or is wanted. Resolution fails on such runtimes.Root cause
During the Jakarta EE migration (commit
93e757413), the bnd-cdiannotationsdirective in the rootpom.xmlwas changed from the empty value used upstream to-cdiannotations: *.bnd's
CDIAnnotationsplugin defaults this directive to*when it is absent, and with*it scans every class in the bundle and unconditionally emits theosgi.extender;osgi.cdirequirement. That made the extender dependency mandatory for every bnd-processed module, not justswagger-jakarta-rest, even though none of the modules use CDI at runtime for this path.(The beans list the scanner produces is not a meaningful CDI bean list, e.g. it includes
Reader$MethodComparator, a nestedComparatorthat cannot be a managed bean — it comes from scanning all classes rather than actual bean-defining annotations.)Change
Revert
-cdiannotationsto the empty value used upstream:With an empty value bnd skips CDI annotation analysis, so no
osgi.cdiextender requirement is generated. OSGi CDI deployments still work, and DS-based non-CDI runtimes resolve again.Runtime CDI autodiscovery is unaffected: that feature is driven by the
META-INF/beans.xmlresource plus the CDIPortableExtension(DiscoveryTestExtension), not by bnd's annotation scan.Fixes #159