How do I add the Service-Component header to the package manifest file in OSGI declarative services?

I am using OSGI Advertiser Services (SCR) to create a component package. I am not interested in using annotation-based XML component files generated by maven-scr-plugin. I am writing a .xml component by hand. But I need a Service-Component header to be added to the MANIFEST file. I am using the maven-bundle-plugin to build the osgi package, any instructions I can give in the plugin config that will add such a header to the manifest file?

some useful links:

felix-SCR

maven-scr-plugin

BND-Service Component

thank

+3


source to share


1 answer


Any header that can be found in the manifest file can be included in the bundle plugin configuration as an element. For example,

<plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.2.0</version>
        <extensions>true</extensions>
        <configuration>
            <instructions>
                <Bundle-SymbolicName>
                  ${pom.artifactId}
                </Bundle-SymbolicName>
                <Service-Component>
                 OSGI-INF/some-file.xml
                </Service-Component>
                ....

      



The line <extensions>true</extensions>

includes arbitrary custom headers, although I believe the Service-Component is included in the set of known headers, so it's not needed here.

+8


source







All Articles