How to convert the third-party jar file to OSGI bundle


URL to download the third party Jar file.
                        http://maven.ibiblio.org/maven2/junit/junit/4.4/

Pre-requisite :
                     - JRE 1.8 
                     - AEM instance up and running

Solution :


  • Create a manifest.txt file and add the below code:


Manifest-Version: 1.0
Created-By: Yourname
Bundle-ManifestVersion: 2
Bundle-Name: JUnit 4.4 bundle
Bundle-Description: Package junit 4.4 in an OSGi bundle
Bundle-Version: 4.4.0
Bundle-ClassPath: .,junit-4.4.jar
Bundle-SymbolicName: org.junit.framework
Export-Package: junit.framework,junit.extensions,org.junit.runner,org.junit,junit.textui


Where -
  • Bundle-ClassPath - Specify the Original jar file name here.
  • Export-Package  - Shows the list of package contained in the junit-4.4.jar file
Use the below command to convert the Third party jar file to OSGI bundle
                   

  • Open the commond propmpt and navigate to the path where manifest.txt & Junit-4.4 jar file was downloaded and created the manifest.txt.



  • Run the below commond to convert custom third-party jar file to OSGI bundle

                             D:\jar cvfm junit-4.4-bundle.jar manifest.txt junit-4.4.jar
where - junit-4.4-bundle.jar is the Osgi bundle name
junit-4.4.jar - downloaded third party Jar file
manifest.txt - the file created above.


That's it - OSGI bundle created(provided there is no external jar file dependency to the Junit-4.4.jar file)

  • Deploy the Junit-4.4-bundle.jar file to AEM instance through OSGI console as shown in below screenshots.


                                    


  • Post the installation of bundle, check the status of bundle as show in below snapshot.











No comments:

Post a Comment