sanre6
sanre6

Reputation: 807

how to add Service-Component header to the bundle manifest file in OSGI declarative services?

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

some useful links :

felix-SCR

maven-scr-plugin

BND-Service Component

thanks

Upvotes: 3

Views: 5259

Answers (1)

Holly Cummins
Holly Cummins

Reputation: 11492

Any header which can go in a manifest file can go in the configuration of the bundle plugin 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 <extensions>true</extensions> line enables arbitrary custom headers, although I believe Service-Component is included in the set of known headers, so it's not needed here.

Upvotes: 8

Related Questions