I agree with tech-idiot, your best bet is spending some time with the karaf-maven-plugin, but you can also set the bundle up by hand, at least to realize that it could be easily achieved with the help of the maven plugin (specially if you have a lot of dependencies).
A basic OSGI bundle (what you refer as "plugin"), is nothing else than a JAR file with a special plain text file in there, the MANIFEST.MF file.
The MANIFEST.MF describes the bundle, its name, description, how you want to activate it, and what the bundle requires to run (its dependencies, or imports), as well as what it has to offer to the other bundles (its exports).
That's a sample manifest file taken from the wikipedia OSGI entry:
Bundle-Name: Hello World
Bundle-SymbolicName: org.wikipedia.helloworld
Bundle-Description: A Hello World bundle
Bundle-ManifestVersion: 2
Bundle-Version: 1.0.0
Bundle-Activator: org.wikipedia.Activator
Export-Package: org.wikipedia.helloworld;version="1.0.0"
Import-Package: org.osgi.framework;version="1.3.0"
The MANIFEST.MF file is usually packed in the META-INF/MANIFEST.MF
folder of your jar, so:
- You can write that file by hand and add it manually to your generated jar.
- Probably, from the last three elements of the sample manifest, you'll only need the
Import-Package
section (noBundle-Activator
and noExport-Package
) - You should declare in the
Import-Package
each required external package import for your app and its version. Keep in mind that the external dependencies you use in your app must be available in the OSGI runtime for your bundle to run.