Option 1 - use the bnd platform to build OSGi packages when you expect frequent additions / updates to Jars or when you can get your dependencies from Maven repositories
We use bnd-platform (I am also the author) to manage third-party dependencies and create OSGi packages. You can use it with two dependencies derived from Maven repositories and local Jars (see README ). If you regularly add or update your dependencies, I suggest you try bnd-platform. This is a plugin for Gradle, you can easily start with this template - just add Jar files and provide the configuration as described in the README project (combine symbolic names, versions) and run gradlew bundles .
Option 2 - use bnd to build OSGi packages when you do it once, or rarely add or update
If you perform this process only once or simply, an easy way to create an OSGi package from an existing Jar is to use bnd directly on the command line . The only thing you need is Java and bnd jar. You can use wrap to try to automatically wrap the jar or create a .bnd file using the instructions for bnd (for example, only to export specific packages).
Example .bnd file:
-classpath: lib/trove-2.0.4.jar -output: gnu.trove-2.0.4.jar Export-Package: *;-split-package:=merge-last;-noimport:=true Import-Package: * Bundle-Version: 2.0.4 Bundle-Name: GNU Trove Collections Plug-in Bundle-SymbolicName: gnu.trove
Call example:
java -jar <path to bnd>.jar trove-2.0.4.bnd
Downloading the bnd Jar is no longer offered directly through the website, a good alternative is to download it from Maven Central .
source share