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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With