Search code examples
javamavenosgiosgi-bundle

OSGi - why is my bundle named "unknown-0.0.0" and MANIFEST.MF file overwritten?


I am new and am learning OSGi now. I'm trying to make maven project with OSGi MANIFEST.MF file inside it. After coding the bundle activator class and the MANIFEST.MF file, I "mvn package" it, and OSGi-install it in console. then this problem occurs where my bundle is named like this instead of the name when I mvn-package-ed it.

unknown-0.0.0

Then, when I checked the MANIFEST.MF file inside the .jar, the inside is like this:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: 5111100191
Created-By: Apache Maven 3.2.1
Build-Jdk: 1.8.0_40

instead of when I coded it like this:

Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.pragprog.HelloWorld
Bundle-Name: HelloWorld
Bundle-Version: 1.0.0
Bundle-Activator: com.pragprog.hello.HelloWorld
Import-Package: org.osgi.framework

I'm guessing that the MANIFEST.MF that I code is somehow not loaded when I mvn package it. Here's my project directory structure

HelloWorld
           /src
                     /main
                            /java
                                       /com.pragprog.hello.HelloWorld.java
                            /resources
                                       /META-INF/MANIFEST.MF
                     /test
                            /java
                            /resources
           /target
                     /**.jar file here**/
           pom.xml

I already searched for this, but couldnt find any clear solution. so how do I solve this?

thanks in advance.


Solution

  • "mvn package", which uses the "maven-assembly-plugin" is not the correct way to create an OSGi bundle. Instead, you should use the "maven-bundle-plugin". Here there is some documentation about how to use it.