Versions Compared

Key

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

...

By default the bundle plugin converts the project's Maven resource directories to into a single <Include-Resource> instruction. If you specify your own <Include-Resource> instruction, this will replace the generated one. To include the generated list of Maven resources in your own <Include-Resource> instruction just add {maven-resources} to the list and it will be expanded automatically.

...

  • <Bundle-SymbolicName> is assumed to be "${groupId}.${artifactId}".
  • <Export-Package> is assumed to be "${groupId}.${artifactId}.*", unless <Private-Package> is specified, then <Export-Package> is assumed to be empty.
  • <Private-Package> is assumed to be empty by default.
  • <Import-Package> is assumed to be "*", which imports everything referred to by the bundle content, but not contained in the bundle.
  • <Include-Resource> is assumed to be generated from the project's Maven resources, typically "src/main/resources/", which will copy the specified project directory hierarchy into the resulting bundle JAR file, mirroring standard Maven behavior.
  • <Bundle-Version> is assumed to be "${pom.version}" with '-' character separator of the qualifier replaced with a '.' character.
  • <Bundle-Name> is assumed to be "${pom.name}".
  • <Bundle-Description> is assumed to be "${pom.description}".
  • <Bundle-License> is assumed to be "${pom.licenses}".
  • <Bundle-Vendor> is assumed to be "${pom.organization.name}".
  • <Bundle-DocURL> is assumed to be "${pom.organization.url}".

Since the plugin creates bundles for OSGi R4, it hard-codes Bundle-ManifestVersion to be '2'. Additionally, it generates imports for every export to ensure package substitutability, which is very important when working with collaborating services. It is possible to override any of these values (except Bundle-ManifestVersion) just by specifying the desired value in the plugin configuration section of the POM file.

...

No Format
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>my-osgi-bundles</groupId>
  <artifactId>examplebundle</artifactId>
  <packaging>bundle</packaging>    <!-- (1) -->
  <version>1.0</version>
  <name>Example Bundle</name>
  <dependencies>
    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.osgi.core</artifactId>
      <version>0<version>1.80.0-incubator<0</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>    <!-- (2) START -->
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Export-Package>com.my.company.api</Export-Package>
            <Private-Package>com.my.company.*</Private-Package>
            <Bundle-Activator>com.my.company.Activator</Bundle-Activator>
          </instructions>
        </configuration>
      </plugin>    <!-- (2) END -->
    </plugins>
  </build>
</project>

...

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

The following features are only available in the 1.1.0-SNAPSHOT version of the maven-bundle-plugin

Embedding dependencies

The Maven Bundle Plugin supports embedding project dependencies into the built bundle using the <Embed-Dependency> instruction listing all dependencies in standard Bundle manifest header syntax:

...