How to specify Bundle-Classpath with bnd-maven-plugin

780 views
Skip to first unread message

Norris Shelton, Jr

unread,
Jul 6, 2015, 9:02:25 AM7/6/15
to bndtool...@googlegroups.com
I'm trying to use the bnd-maven-plugin.  Everything is working perfectly, but I get it to generate the Bundle-Classpath.  There doesn't appear to be anything on the internet about how to get the plugin to generate it, even though bnd does support it.  Does anyone have any information on this?

Neil Bartlett

unread,
Jul 6, 2015, 9:04:47 AM7/6/15
to bndtool...@googlegroups.com
Hello Norris,

As with any OSGi header, you can just write that header directly in your bnd.bnd file and it will be generated into the MANIFEST.MF. The documentation is here: http://bnd.bndtools.org/chapters/800-headers.html

Regards,
Neil


On 6 Jul 2015, at 14:02, Norris Shelton, Jr <norris....@gmail.com> wrote:

I'm trying to use the bnd-maven-plugin.  Everything is working perfectly, but I get it to generate the Bundle-Classpath.  There doesn't appear to be anything on the internet about how to get the plugin to generate it, even though bnd does support it.  Does anyone have any information on this?

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norris Shelton, Jr

unread,
Jul 6, 2015, 9:41:26 AM7/6/15
to bndtool...@googlegroups.com
How does the bnd-maven-plugin specify a bnd.bnd file?  I have found that the default name is bnd.bnd.  This is the first time I saw a reference to that.  
I need to specify that all files in the lib directory is included in the classpath.  Would that be:

Bundle-Classpath::=lib

Norris Shelton, Jr

unread,
Jul 6, 2015, 10:04:29 AM7/6/15
to bndtool...@googlegroups.com
I created a file named bnd.bnd and placed it in the root directory with my pom.xml.

The file contains:
Bundle-Classpath:.,lib/**

The output in the Manifest.mf was:
Bundle-Classpath: .,lib/**

My environment is being used for a demo so I can't deploy it to see if it works till later.

BJ Hargrave

unread,
Jul 6, 2015, 10:19:37 AM7/6/15
to bndtool...@googlegroups.com
On Jul 6, 2015, at 10:04 , Norris Shelton, Jr <norris....@gmail.com> wrote:

I created a file named bnd.bnd and placed it in the root directory with my pom.xml.

The file contains:
Bundle-Classpath:.,lib/**

You will need to (1) include all the jars in your bundle with -includeresource and (2) specify all the included jar files in the Bundle-Classpath statement.
-- 

BJ



Norris Shelton, Jr

unread,
Jul 6, 2015, 1:47:35 PM7/6/15
to bndtool...@googlegroups.com
Is there no way for it to list them automatically?  I don't have to tell it which packages to include in Import-Packages.  Why would I have to manually note the jars that include those dependencies?

BJ Hargrave

unread,
Jul 6, 2015, 1:52:23 PM7/6/15
to bndtool...@googlegroups.com
On Jul 6, 2015, at 13:47 , Norris Shelton, Jr <norris....@gmail.com> wrote:

Is there no way for it to list them automatically?  I don't have to tell it which packages to include in Import-Packages.  Why would I have to manually note the jars that include those dependencies?

Well the packages can be computed by examining the class files in your bundle. But bnd cannot guess what jar files you want embedded in your bundle.

Look at the bnd macros like ${findfile} [1] to help with building a list of the files to include.

Neil Bartlett

unread,
Jul 6, 2015, 1:53:15 PM7/6/15
to bndtool...@googlegroups.com
Curious question! Why would you expect bnd to know about all the JARs on the filesystem that your code might depend on?

Actually there is a way to write a macro that expands all the files in a directory and puts them on Bundle-Classpath, but are you really sure you want to go there? It seems you’re going to be creating a gigantic bundle, does it really need to contain all of the packages of all those JARs?

Neil

Norris Shelton, Jr

unread,
Jul 6, 2015, 2:40:01 PM7/6/15
to bndtool...@googlegroups.com
Me thinks we are abusing OSGi and should just do it the right way and deploy the dependencies separately and let the import take care of it.

Peter Kriens

unread,
Jul 8, 2015, 4:35:05 AM7/8/15
to bndtool...@googlegroups.com
On 6 jul. 2015, at 20:40, Norris Shelton, Jr <norris....@gmail.com> wrote:
Me thinks we are abusing OSGi and should just do it the right way and deploy the dependencies separately and let the import take care of it.

Me is probably right … though when you port a large classic Java application to OSGi the mess is often so big that containing it first in one bundle is the only way to triage it.

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages