Versions Compared

Key

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

...

No Format
META-INF/MANIFEST.MF
LICENSE
META-INF/
META-INF/maven/
META-INF/maven/org.apache.felix/
META-INF/maven/org.apache.felix/org.apache.felix.log/
META-INF/maven/org.apache.felix/org.apache.felix.log/pom.properties
META-INF/maven/org.apache.felix/org.apache.felix.log/pom.xml
NOTICE
org/
org/apache/
org/apache/felix/
org/apache/felix/log/
org/apache/felix/log/impl/
org/apache/felix/log/impl/Activator.class
org/apache/felix/log/impl/Log.class
org/apache/felix/log/impl/LogEntryImpl.class
org/apache/felix/log/impl/LogException.class
org/apache/felix/log/impl/LogListenerThread.class
org/apache/felix/log/impl/LogNode.class
org/apache/felix/log/impl/LogNodeEnumeration.class
org/apache/felix/log/impl/LogReaderServiceFactory.class
org/apache/felix/log/impl/LogReaderServiceImpl.class
org/apache/felix/log/impl/LogServiceFactory.class
org/apache/felix/log/impl/LogServiceImpl.class
org/osgi/
org/osgi/service/
org/osgi/service/log/
org/osgi/service/log/LogEntry.class
org/osgi/service/log/LogListener.class
org/osgi/service/log/LogReaderService.class
org/osgi/service/log/LogService.class
org/osgi/service/log/package.html
org/osgi/service/log/packageinfo

Building the Plugin

The plugin is hosted at the Apache Felix project. The following steps describe how to build and install the plugin into your local Maven2 repository.

Using the SVN client of your choice, checkout the maven-bundle-plugin project.

No Format

$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin

Using Maven2, build and install the maven-bundle-plugin by issuing the following Maven2 command in the project directory that was created as a result of the previous step.

No Format

$ mvn install

Goals

The maven-bundle-plugin also provides additional functionality via some Maven goals. Command-line execution of a goal is performed as follows:

No Format

mvn org.apache.felix:maven-bundle-plugin:GOAL

Where GOAL is one of the following:

  • bundle - build an OSGi bundle jar
    configuration options:
    • manifestLocation defaults to ${project.build.outputDirectory}/META-INF
    • unpackBundle unpack bundle contents to output directory, defaults to false
    • excludeDependencies exclude all dependencies from the classpath given to Bnd, defaults to false
    • supportedProjectTypes defaults to "jar","bundle"
  • bundleall - build an OSGi bundle jar for all transitive dependencies
    configuration options:
    • supportedProjectTypes defaults to "jar","bundle"
  • wrap - as above, but limited to the first level of dependencies
    configuration options:
    • supportedProjectTypes defaults to "jar","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>

Building the Plugin

The plugin is hosted at the Apache Felix project. The following steps describe how to build and install the plugin into your local Maven2 repository.

Using the SVN client of your choice, checkout the maven-bundle-plugin project.

No Format

$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin

Using Maven2, build and install the maven-bundle-plugin by issuing the following Maven2 command in the project directory that was created as a result of the previous step.

No Format

$ mvn install

Goals

The maven-bundle-plugin also provides additional functionality via some Maven goals. Command-line execution of a goal is performed as follows:

No Format

mvn org.apache.felix:maven-bundle-plugin:GOAL

Where GOAL is one of the following:

  • bundle - build an OSGi bundle jar
    configuration options:
    • manifestLocation
    manifest - create an OSGi manifest for the current project
    configuration options:
    • manifestLocation defaults to ${project.build.outputDirectory}/META-INF
    • unpackBundle unpack bundle contents to output directory, defaults to false
    • excludeDependencies exclude all dependencies from the classpath given to Bnd, defaults to false
    • supportedProjectTypes defaults supportedProjectTypes defaults to "jar","bundle"

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:

...

  • bundleall - build an OSGi bundle jar for all transitive dependencies
    configuration options:
    • supportedProjectTypes defaults to "jar","bundle"
  • wrap - as above, but limited to the first level of dependencies
    configuration options:
    • supportedProjectTypes defaults to "jar","bundle"
  • manifest - create an OSGi manifest for the current project
    configuration options:
    • manifestLocation defaults to ${project.build.outputDirectory}/META-INF
    • supportedProjectTypes defaults to "jar","bundle"

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".

The following features are only available in

...

versions after 1.

...

0.0

...

Embedding dependencies

The Maven Bundle Plugin supports embedding of selected project dependencies inside the bundle by using the <Embed-Dependency> instruction:

...

Code Block
xml
xml
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>

Embed-Dependency and Export-Package

If you embed a dependency with <Embed-Dependency>, and your <Export-Package> or <Private-Package> instructions match packages inside the embedded jar, you will see some duplication inside the bundle. This is because the <Export-Package> and <Private-Package> instructions will result in classes being inlined in the bundle, even though they also exist inside the embedded jar. If you want to export packages from an embedded dependency without such duplication then you can either inline the dependency, or use a new BND instruction called <_exportcontents>.

<_exportcontents> behaves just like Export-Package, except it doesn't change the content of the bundle, just what content should be exported.

OBR integration

The latest Maven Bundle Plugin automatically updates the local OBR repository.xml file during the install phase, using a default location of:

...

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

Eclipse/PDE integration

It is possible to configure the Maven Bundle Plugin to put the bundle manifest where Eclipse/PDE expects it, and use the Maven Dependency Plugin to arrange for any embedded dependencies to appear in a local directory that matches the Bundle-ClassPath entries. Here is an example POM that does this:

...

to create the appropriate Eclipse files and manifest, and also handle any embedded entries. The pax:eclipse goal extends eclipse:eclipse, and supports the same parameters.

Unpacking bundle contents to 'target/classes'

Once in a while you may create a bundle which contains additional classes to the ones compiled from src/main/java, for example when you embed the classes from another jar. This can sometimes cause unforeseen problems in Maven, as it will use the output directory (target/classes) rather than the final bundle, when compiling against projects in the same reactor (ie. the same build).

...

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>

Using an existing MANIFEST.MF file

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

...