On 14.04.2013 13:02, Stuart McCulloch wrote:
On 14 Apr 2013, at 09:59, Philippe Marschall wrote:

Hi

I'm trying to create a "wrapper bundle", a bundle containing several JARs using 
the maven-bundle-plugin. The JARs should just be added to the root of the bundle the 
Bundle-ClassPath.

My understanding is that inline=false can be used to achieve this. However when 
I do this the JARs get added to the bundle root _and_ expanded inside the 
bundle.

The see attached POM to reproduce the issue. The relevant section is:

<instructions>
  <Import-Package>
    *;-noimport:=true

^ -noimport:=true only makes sense on export related instructions, see 
http://www.aqute.biz/Bnd/Format#export-package

  </Import-Package>
  <Export-Package>*;-split-package:=merge-last</Export-Package>

^ this is the reason you're getting inlined content, see: 
http://felix.apache.org/site/apache-felix-bundle-plugin-faq.html#ApacheFelixBundlePluginFAQ-WhenIembedadependencywhydoIseeduplicatedcontent%253F

you should use _exportcontents when exporting packages from embedded content

<Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
  <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.6</Bundle-RequiredExecutionEnvironment>
  <Embed-Dependency>*;scope=provided;inline=false</Embed-Dependency>

^ inline=false is the default setting, so this isn't needed here once you 
change the Export-Package instruction to _exportcontents

  <Embed-Transitive>true</Embed-Transitive>
  <Bundle-ClassPath>{maven-dependencies}</Bundle-ClassPath>

^ this isn't necessary, the embed instruction will take care of the 
Bundle-ClassPath for you (you'd only use this if you wanted to add additional 
jars or folders)

</instructions>

Try the following instructions:

    <instructions>
       
<Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
       <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
       
<Bundle-RequiredExecutionEnvironment>JavaSE-1.6</Bundle-RequiredExecutionEnvironment>
       <Embed-Dependency>*;scope=provided</Embed-Dependency>
       <Embed-Transitive>true</Embed-Transitive>
       <_exportcontents>*;-split-package:=merge-last</_exportcontents>
    </instructions>

You could also try adding:

    <Import-Package>*;resolution:=optional</Import-Package>

if you're having issues with unresolved imports at runtime that aren't actually 
required (ie. when you know you don't use the class that requires this import)

Thank you that fixes all my issues.

Cheers
Philippe

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

Reply via email to