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

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

<-foo>bar</-foo> 

I checked the official page for the maven-bundle-plugin and they said that it should start with the '-' character

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

The description of the chain description does not seem to contain this information either. to perform some special processing and is not copied to the manifest.

+4
source share
2 answers

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

 <_foo>bar</_foo> 

This is really vaguely described on the FAQ page:

(this is & lt; _exportcontents> in the POM, because the tag cannot begin with '-')

This improvement can also be found in your problem tracking.

+8
source

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

Configure the plugin as follows:

 <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 instructions, for example.

  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: * 

Note: there is a minus sign in the _include tag before the file name!

An example of real life can be found here:

pom.xml file and osgi.bnd file .

+5
source

Source: https://habr.com/ru/post/1489488/


All Articles