Adding Maven support to OSGi applications

You can add Maven support to OSGi applications by converting the project to a Maven project. The converted project remains an OSGi application but configurations for the bundle, such as its ID, version, and its dependencies are defined in a pom.xml file.

Procedure

  1. Right-click the OSGi application and select Configure > Convert to Maven Project.
  2. Complete the Create New POM dialog box.
    Enter a Group Id, Artifact Id, and Version or accept the defaults. Optionally, enter a Name and Description. For Packaging, accept the default value.
  3. Click Finish.

Results

The following changes are made to the project:
  • A Project Object Model (POM) file, pom.xml, is generated for your project and contains all configuration, including the dependencies, from the existing manifest.mf file.
  • The existing manifest.mf file is updated to indicate that the file is generated by the Maven project. Do not edit the generated manifest.mf file.
New dependencies that you add to your project are specified in the pom.xml. Changes in the pom.xml file are automatically generated in the manifest.mf file.

What to do next

If your project uses WebSphere® Application Server APIs, you must manually add them as a dependency in your POM file:
  1. Install the server APIs in your Maven repository. For instructions, see Installing the server APIs into the Maven repository.
    Tip: It is only necessary to install the API to the local repository one time.
  2. Add a dependency to the APIs. If you added the API to your Maven repository, right-click the project and select Maven > Add Dependency. Select the module; the Group Id and Artifact Id fields are updated. Set Scope to provided. Click OK.

For details of how to export packages from a JAR file in a Maven bundle, see the following subtopic: