You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Gay David (Annecy)" <dg...@axway.com> on 2010/08/13 17:35:05 UTC

Bundle plugin and <_exportcontents> version

Hi all,
 
I try to use the Maven Bundle Plugin to create a bundle that embed 
several other non-osgi jars. I'll take an example with the well known
Apache Commons IO, but my real case is to be able to embed several
internal libraries.
 
If I use this pom.xml :
 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0
<http://maven.apache.org/POM/4.0.0> "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
<http://maven.apache.org/POM/4.0.0>
http://maven.apache.org/maven-v4_0_0.xsd
<http://maven.apache.org/maven-v4_0_0.xsd> ">
 
 <!-- General information -->
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.sample</groupId>
 <artifactId>commons</artifactId>
 <packaging>bundle</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <description>OSGi bundelization of many externals commons
libraries</description>
 
 <!-- Build -->
 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.1.0</version>
    <extensions>true</extensions>
    <configuration>
     <unpackBundle>false</unpackBundle>
     <instructions>
      <Embed-Dependency>commons-io;inline=false</Embed-Dependency>
      <_exportcontents>*</_exportcontents>
     </instructions>
    </configuration>
   </plugin>
  </plugins>
 </build>
 
 <!-- Dependencies -->
 <dependencies>
  <dependency>
   <groupId>commons-io</groupId>
   <artifactId>commons-io</artifactId>
   <version>1.4</version>
  </dependency>
 </dependencies>
 
</project>
 
The generated Manifest is :
 
(...)
Export-Package: org.apache.commons.io.output;uses:="org.apache.commons
 .io",org.apache.commons.io.filefilter;uses:="org.apache.commons.io",o
 rg.apache.commons.io.comparator;uses:="org.apache.commons.io",org.apa
 che.commons.io.input;uses:="org.apache.commons.io",org.apache.commons
 .io;uses:="org.apache.commons.io.filefilter,org.apache.commons.io.out
 put"
(...)
Import-Package: org.apache.commons.io;version="1.4",org.apache.commons
 .io.comparator;version="1.4",org.apache.commons.io.filefilter;version
 ="1.4",org.apache.commons.io.input;version="1.4",org.apache.commons.i
 o.output;version="1.4"
(...)
 
 
My problem is that the Export-Package don't have the version="1.4"
information
automatically added. Is it a normal behavior ? Why can't the bundle
plugin do that
automatically ? it's done for the Import-Package ! Is there a special
syntax that
I haven't found in BND ?
 
I know I can modify "manually" in the pom the _exportcontents directive
by adding :
<_exportcontents>*;version="1.4"</_exportcontents> but I like to apply
the rule
"Don't Repeat Yourself" : the version information is already in the
dependency !
Also, if I add more and more dependencies to embed in this bundle, I
would
prefer if it's only a matter of adding a Maven dependency.
 
 
Thanks a lot for your helps
Regards
David