You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Rabe, Jens" <je...@iwes.fraunhofer.de> on 2014/10/08 18:39:15 UTC

Is it possible to "shade" non-OSGi projects into bundle?

Hello,

I want to create a self-contained OSGi bundle which uses some Spring/JPA features like the auto generated repositories (PagingAndSortingRepository). I configured my pom.xml as a bundle, and it builds correctly. The problem is though, non-Maven dependencies like the Spring stuff cannot easily be incorporated into an OSGi runtime. There are functions like Karaf's wrap which works well (converts non-OSGi bundles to OSGi on the fly), but that causes all sorts of stuff to be exported and causing problems like multiple dependency chains resolving to a single package.

In Eclipse using Equinox in the pre-Maven days, I always did the following:
- I created a "lib" folder in my project
- copied all non-OSGi dependencies there
- adjusted the build.properties to include them
- set the Bundle-Classpath to include these jars

This worked fine. Is it somehow possible to do this with maven-shade-plugin as well?

Any help would be greatly appreciated,
Jens

RE: Is it possible to "shade" non-OSGi projects into bundle?

Posted by "Rabe, Jens" <je...@iwes.fraunhofer.de>.
Hello Henry,

thanks for the quick reply. I will try this.

Regards,
Jens
________________________________________
From: Henry Saginor [hsaginor@gmail.com]
Sent: Wednesday, October 08, 2014 9:26 PM
To: users@felix.apache.org
Subject: Re: Is it possible to "shade" non-OSGi projects into bundle?

Hi Jens,

You can add non-OSGi dependencies as embedded dependencies to your project using maven-bundle-plugin [1] via Embed-Dependency. In this case the embedded dependency will be added to your bundles jar and to Bundle-ClassPath in it’s manifest.
This should also avoid other class loader issues you mentioned. It will not export any packages from the dependency unless you explicitly specify them.

Hope this helps.

Henry

[1]  http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

On Oct 8, 2014, at 9:39 AM, Rabe, Jens <je...@iwes.fraunhofer.de> wrote:

> Hello,
>
> I want to create a self-contained OSGi bundle which uses some Spring/JPA features like the auto generated repositories (PagingAndSortingRepository). I configured my pom.xml as a bundle, and it builds correctly. The problem is though, non-Maven dependencies like the Spring stuff cannot easily be incorporated into an OSGi runtime. There are functions like Karaf's wrap which works well (converts non-OSGi bundles to OSGi on the fly), but that causes all sorts of stuff to be exported and causing problems like multiple dependency chains resolving to a single package.
>
> In Eclipse using Equinox in the pre-Maven days, I always did the following:
> - I created a "lib" folder in my project
> - copied all non-OSGi dependencies there
> - adjusted the build.properties to include them
> - set the Bundle-Classpath to include these jars
>
> This worked fine. Is it somehow possible to do this with maven-shade-plugin as well?
>
> Any help would be greatly appreciated,
> Jens


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Is it possible to "shade" non-OSGi projects into bundle?

Posted by Henry Saginor <hs...@gmail.com>.
Hi Jens,

You can add non-OSGi dependencies as embedded dependencies to your project using maven-bundle-plugin [1] via Embed-Dependency. In this case the embedded dependency will be added to your bundles jar and to Bundle-ClassPath in it’s manifest.
This should also avoid other class loader issues you mentioned. It will not export any packages from the dependency unless you explicitly specify them.

Hope this helps.

Henry

[1]  http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
 
On Oct 8, 2014, at 9:39 AM, Rabe, Jens <je...@iwes.fraunhofer.de> wrote:

> Hello,
> 
> I want to create a self-contained OSGi bundle which uses some Spring/JPA features like the auto generated repositories (PagingAndSortingRepository). I configured my pom.xml as a bundle, and it builds correctly. The problem is though, non-Maven dependencies like the Spring stuff cannot easily be incorporated into an OSGi runtime. There are functions like Karaf's wrap which works well (converts non-OSGi bundles to OSGi on the fly), but that causes all sorts of stuff to be exported and causing problems like multiple dependency chains resolving to a single package.
> 
> In Eclipse using Equinox in the pre-Maven days, I always did the following:
> - I created a "lib" folder in my project
> - copied all non-OSGi dependencies there
> - adjusted the build.properties to include them
> - set the Bundle-Classpath to include these jars
> 
> This worked fine. Is it somehow possible to do this with maven-shade-plugin as well?
> 
> Any help would be greatly appreciated,
> Jens