Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use bnd directives from maven-bundle-plugin?

How can I use bnd directives instruction from maven-bundle-plugin? bnd directives are starting with a '-' character, and this is an invalid xml tag:

<-foo>bar</-foo>

I have checked the official page for maven-bundle-plugin, and they said that it should start with a '-' character as well:

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.

The bundle goal description doesn't seem to have this information as well. to perform some special processing and is not copied to the manifest.

like image 767
ceilfors Avatar asked Dec 12 '22 13:12

ceilfors


2 Answers

Replace the '-' character with '_' character. This will work:

<_foo>bar</_foo>

It is actually vaguely described in the FAQ page:

(this is <_exportcontents> in the POM because a tag can't start with '-')

This improvement also can be found in their issue tracker.

like image 75
ceilfors Avatar answered Dec 14 '22 03:12

ceilfors


There is an alternative way to define the bnd instructions with less xml clutter:

Configure the plugin like this:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <_include>-osgi.bnd</_include>
        </instructions>
    </configuration>
</plugin>

and provide a file (here: osgi.bnd) with the instructions, e.g.

 Import-Package: !javax.servlet,\
  !org.apache.avalon.framework.logger,\
  org.apache.commons.collections;version="[1.0,2)",\
  org.apache.commons.collections.comparators;version="[1.0,2)",\
  org.apache.commons.collections.keyvalue;version="[1.0,2)",\
  org.apache.commons.collections.list;version="[1.0,2)",\
  org.apache.commons.collections.set;version="[1.0,2)",\
  !org.apache.log,\
  !org.apache.log4j,\
  *
 Export-Package: *

Remark: There is a minus sign in the _include tag before the filename!

A real life example can be found here:

pom.xml file and osgi.bnd file.

like image 38
evandor Avatar answered Dec 14 '22 02:12

evandor