# The OSGi Plugin

The OSGi plugin provides a factory method to create an object. `OsgiManifest` extends . To learn more about generic manifest handling, see sub:manifest. If the Java plugins is applied, the OSGi plugin replaces the manifest object of the default jar with an `OsgiManifest` object. The replaced manifest is merged into the new one.

The OSGi plugin makes heavy use of Peter Kriens BND tool.

## Usage

To use the OSGi plugin, include in your build script:

## Implicitly applied plugins

Applies the Java base plugin.

## Tasks

This plugin does not add any tasks.

## Dependency management

TBD

## Convention object

The OSGi plugin adds the following convention object:

### Convention properties

The OSGi plugin does not add any convention properties to the project.

### Convention methods

The OSGi plugin adds the following methods. For more details, see the API documentation of the convention object.

### OSGi methods

Method | Return Type | Description
osgiManifest() |  | Returns an OsgiManifest object.
osgiManifest(Closure cl) |  | Returns an OsgiManifest object configured by the closure.

The classes in the classes dir are analyzed regarding there package dependencies and the packages they expose. Based on this the Import-Package and the Export-Package values of the OSGi Manifest are calculated. If the classpath contains jars with an OSGi bundle, the bundle information is used to specify version information for the Import-Package value. Beside the explicit properties of the `OsgiManifest` object you can add instructions.

The first argument of the instruction call is the key of the property. The other arguments form the value. They are joined by Gradle with the `,` separator. To learn more about the available instructions have a look at the BND tool.