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: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to