Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are also new instructions available from the underlying BND tool, which continues to be improved independently; for the latest see BND documentation.

The default goal bundle will be initialized by setting the <packaging> entry to "bundle".

Adding OSGi metadata to existing projects without changing the packaging type

If you want to keep your project packaging type (for example "jar") but would like to add OSGi metadata
you can use the manifest goal to generate a bundle manifest. The maven-jar-plugin can then be used to
add this manifest to the final artifact. For example:

Code Block
xml
xml

<plugin>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <archive>  
      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
    </archive> 
  </configuration>
</plugin>  
<plugin>   
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <executions>
    <execution>
      <id>bundle-manifest</id>
      <phase>process-classes</phase>
      <goals>    
        <goal>manifest</goal>
      </goals>   
    </execution>
  </executions>
</plugin>

The following features are only available in the 1.1.0-SNAPSHOT version

...

The easiest way to get around this Maven 'feature' is to unpack the contents of the bundle to the output directory after the packaging step, so the additional classes will be found where Maven expects them. Thankfully there is now an easy option to do this in the bundle-plugin:

Code Block
xml
xml
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
  <unpackBundle>true</unpackBundle>
  <instructions>
    <!-- bnd instructions -->
  </instructions>
</configuration>

...

If you have an existing manifest, you can add this to the Bnd instructions, like so:

Code Block
xml
xml
<_include>src/main/resources/META-INF/MANIFEST.MF</_include>
<Export-Package>org.example.*</Export-Package>

...