You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Holger Hoffstätte <ho...@googlemail.com> on 2011/10/27 16:06:59 UTC

Fun with bundle-plugin, embedding and merging split packages

..and now for something complicated :)

I'm embedding a third-party jar and need to re-export all its packages. In
theory I should be able to specify inline=true since I get the classes of
the exported packages anyway, so there is no need to still keep the
complete jar embedded. Turns out this doesn't work when overriding a class
of the jar (bugfix).

The following works, as it plasters my bugfixed class over the jar
contents, but - as expected - results in both exported inlined classes and
an extraneous embedded jar:

<Embed-Dependency>artifact;groupId=com.vendor;inline=false</Embed-Dependency>
<Export-Package>!${bundle.namespace}.internal.*,com.vendor.*;-split-package:=merge-first;version="${project.version}"</Export-Package>

Now I've been trying to get the extraneous jar out of my bundle, but to no
avail. No matter what I try in terms of bnd instructions, the resulting
bundle always contains the original class, not my fixed version. This
leads me to believe that inlining=true and split-package handling does not
really work together at all.

Plugin is 2.3.5, but this behaviour was already the case with older
versions. Any suggestions?

thanks
Holger

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


Re: Fun with bundle-plugin, embedding and merging split packages

Posted by Holger Hoffstätte <ho...@googlemail.com>.
On 27.10.2011 16:59, Stuart McCulloch wrote:
> This is because embedding uses bnd's Include-Resource instruction,
> which is independent of the exported/private package processing.
> Includes are processed after the packages and currently always
> overwrite any existing resource.

Thanks for the explanation - as I expected, since nothing I changed seemed
to help.

> Note that as well as true / false the inline attribute also supports a
> file pattern, so you can exclude the Foo class with:
> 
> <Embed-Dependency>artifact;groupId=com.vendor;inline=!**/Foo.class</Embed-Dependency>

yay! This is exactly what I was looking for. At first I got strange new
errors about an inner class of Foo not being found, but that was a
mismatch between the old and new (overriding) inner classes, and was
easily fixed by using inline=!**/Foo*.class so that the internals were
skipped as well. Now my bundle is 500k smaller - nice!

Thanks for the quick help!
Holger

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


Re: Fun with bundle-plugin, embedding and merging split packages

Posted by Stuart McCulloch <mc...@gmail.com>.
On 27 Oct 2011, at 15:06, Holger Hoffstätte wrote:

> ..and now for something complicated :)
> 
> I'm embedding a third-party jar and need to re-export all its packages. In
> theory I should be able to specify inline=true since I get the classes of
> the exported packages anyway, so there is no need to still keep the
> complete jar embedded. Turns out this doesn't work when overriding a class
> of the jar (bugfix).

This is because embedding uses bnd's Include-Resource instruction, which is independent of the exported/private package processing. Includes are processed after the packages and currently always overwrite any existing resource.

> The following works, as it plasters my bugfixed class over the jar
> contents, but - as expected - results in both exported inlined classes and
> an extraneous embedded jar:
> 
> <Embed-Dependency>artifact;groupId=com.vendor;inline=false</Embed-Dependency>
> <Export-Package>!${bundle.namespace}.internal.*,com.vendor.*;-split-package:=merge-first;version="${project.version}"</Export-Package>

Note that as well as true / false the inline attribute also supports a file pattern, so you can exclude the Foo class with:

   <Embed-Dependency>artifact;groupId=com.vendor;inline=!**/Foo.class</Embed-Dependency>

This will then leave your bugfixed class in place - however note that this pattern is limited and requires you to know which class/package you want omitted.

An alternative is to not use Embed-Dependency and instead rely solely on Export-Package / Private-Package to pull resources from the dependency - you can then use the split package merging policy to pick your bugfixed class over the resources from the dependency. The downside of this approach is that you need to tell bnd what packages to export / keep private, rather than just inlining the full jar.

> Now I've been trying to get the extraneous jar out of my bundle, but to no
> avail. No matter what I try in terms of bnd instructions, the resulting
> bundle always contains the original class, not my fixed version. This
> leads me to believe that inlining=true and split-package handling does not
> really work together at all.
> 
> Plugin is 2.3.5, but this behaviour was already the case with older
> versions. Any suggestions?
> 
> thanks
> Holger
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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