3

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

sanre6
  • 797
  • 2
  • 11
  • 28

1 Answers1

8

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.

Holly Cummins
  • 10,767
  • 3
  • 23
  • 25
  • i thought maven-bundle-plugin would not understand what service-component element is , works nicely thank you – sanre6 Mar 08 '12 at 05:09
  • 2
    The maven-bundle plugin just passes the header along, it does not do anything with. Which is actually not completely true because you can also define components in the header.See http://www.aqute.biz/Bnd/Components Curious why you do not want to use the bnd annotations? – Peter Kriens Mar 08 '12 at 08:30
  • nothing as such , just i did not want to introduce the annotation api depedency in my code . – sanre6 Mar 15 '12 at 15:31