如何在 Apache Felix maven-bundle-plugin 中设置 Provide-Capability header?

How do I set the Provide-Capability header in the Apache Felix maven-bundle-plugin?

我们使用 Apache Felix maven-bundle-plugin 为我们的片段包生成清单。此片段包旨在覆盖 Liferay host 包上的资源。 Liferay DXP documentation specifies that the developer ought to include a Provide-Capability header in their manifest to override the host bundle's resources. However, the Apache Felix maven-bundle-plugin documentation 没有指定如何在插件中这样做,或者这是否可能。

我们有什么方法可以使用 Apache Felix maven-bundle-plugin 添加 Provide-Capability header 吗?

对于 maven-bundle-plugin,您只需将 <Provide-Capability>...</Provide-Capability> 放入插件配置中,确保将 ... 替换为 header 的所需值。

事实上,您可以添加 OSGi spec. It's specified in the documentation 中定义的任何清单 header,如下所示:

The BND library underlying the plugin defines instructions to direct its behavior. For this Maven plugin, these instructions are issued in the plugin configuration section of the POM file, as was illustrated above. BND recognizes three types of instructions

1. Manifest headers - Any instruction that starts with a capital letter will appear in the resulting bundle's manifest file; the value for the header will either be copied, augmented, or generated by BND depending on the instruction.

  1. Variables - Any instruction starting with a lowercase letter is assumed to be a variable in the form of a name-value pair, such as version=3.0, that can be used for property substitution, but is not copied to the manifest.

  2. Directives - Any instruction starting with a '-' character is considered to be a directive that informs BND to perform some special processing and is not copied to the manifest