Versions Compared

Key

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

...

For the libraries that are not available as OSGi bundles, we need to create the bundle on our own. The tool that can help is Bnd. In the attachment of the page there is bnd.jar that can be used to generate the OSGi bundles from the existing jars via command line.: 

Code Block
java -jar bnd.jar wrap -properties bnd_properties.bnd [path/to/the/jar/file.jar]

Executing following command will create the jarName.bar file with the MANIFEST.MF file included. There is always the need to manually alter the manifest file after the generation. Please take care of the following:

  1. Make sure that the Bundle-Version: header has the same version number as the library that we try to modify to bundle. This means that MANIFEST.MF for the guava-11.0.1 has to have the Bundle-Version: 11.0.1 header. Note that it is necessary to have a valid OSGi version, meaning that for example Hibernate libraries with 3.5.3-Final are not correct versions for OSGi and have to be changed to 3.5.3.FINAL.
  2. Change the Bundle-SymbolicName: into the format: info.novatec.[artifact name]. This means that the old ivy dependency of 

    Code Block
    <dependency org="org.apache.httpcomponents" name="httpclient" rev="4.1.1" />

    should have the  Bundle-SymbolicName: info.novatec.httpclient in the manually generated bundle. 

  3. Add the Bundle-Vendor: Novatec GmbH to the list of headers

After editing the manifest file, please update the name of the .bar file to the info.novatec.jarName.jar and upload the jar to our Nexus server with the following GAV parameters: 

...

The content of the bnd properties file is as follows:

Code Block
languagebash
titlebnd_properties.bnd
version=3.2.16
artifact=spring-aop
Bundle-Version: ${version}
Bundle-Name: info.novatec.${artifact}
Bundle-SymbolicName: info.novatec.${artifact}
Export-Package: *;version="${version}"

The bnd_properties.bnd file was used to wrap the spring-aop-3.2.16.RELEASE.jar file into an OSGi bundle. You have to modify the value of version (line 1) and artifact (line 2) to match your particular case. Leave the other lines untouched to ensure that your library is wrapped according to our guidelines.

Info
titleImportant
  • Make sure that the version you specify in the properties file matches the version of the library that you want to wrap.
  • A version string of 3.5.3-RELEASE is invalid because of the "-" and must be changed appropriately to 3.5.3.RELEASE to be valid.

Running the command as outlined above creates a *.bar file with the same name as the wrapped *.jar file. Change the file extension from *.bar to *.jar. You can overwrite the  default output name of the jar and directory by setting the -output property:

Code Block
languagebash
java -jar bnd.jar wrap -properties bnd_properties.bnd -output [target/path/of/your/bundle.jar] [source/path/of/your/library.jar]

Uploading to external Nexus

After creating such a jar, it needs to be uploaded to the external Nexus we use, so that the library can be resolved by Ivy. Please use the 3rd Party Dependencies repository on the Nexus for such upload and correctly specify the GAV parameters when uploading. Log-in credentials for the external Nexus can be found on the /wiki/spaces/IN/pages/5701787 page. on the Nexus for such uploads and correctly specify the GAV parameters when uploading a wrapped jar. Log-in credentials for the external Nexus can be found on the /wiki/spaces/IN/pages/5701787 page. 

Select GAV parameters as GAV Definition. 

ParameterValue

Group

Use the original group of the wrapped libary (e.g., org.springframework)

Artifact

info.novatec.${artifact}

Version

${version}

Use the values you specified in your bnd properties file to replace ${artifact} and ${version} in the table above.

Specifying dependencies

In the manifest for the Commons, CommonsCS and inspectIT projects we list all required plug-ins as a dependency via Required Plug-ins option.

...