Use Case: You have a non osgi jar file that you want to integrate in CQ as a bundle. You want to create fragment bundle (See option 4)
Solution: There are various way you can do this, Here is some options.
Option 1:
http://dev.day.com/content/kb/home/cq5/Development/ApacheFelix/ConvertAJarIntoOsgiBundle.html
jar cvfm <Your bundle name> manifest.txt <Non OSGI Jar file>
manifest.txt file will look like this
Manifest-Version: 1.0
Created-By: yogesh
Bundle-ManifestVersion: 2
Bundle-Name: <Your Bundle name>
Bundle-Description: JTMB bundle for dvdRental
Bundle-Version: 4.4.0
Bundle-ClassPath: .,<Your jar file>
Bundle-SymbolicName: <Bundle Symbolic name>
Export-Package: <Package you want to export, Just export selective package>
Import-Package: <Package this jar file is importing from others, You can put * as well>
After bundle is created you can put them in /apps/<your app>/install folder, So that they can be picked by Felix. Once in Install Folder you will see them in felix console
Option 2: (Only till CQ5.4)
Other option is use sling boot delegation http://dev.day.com/content/kb/home/cq5/Development/SlingBootdelegation.html to add third party jar.
Option 3:
Using BND tool
http://help.adobe.com/en_US/enterpriseplatform/10.0/AEPDeveloperGuide/WS562be5d616a63050-c62634713136615f38-8000.html
1) Install bnd.jar
2) Use command java -jar bnd.jar wrap {YourJarfile}.jar
3) Rename .bar file to {file-name}-bundle.jar
4) Put it in install folder or install using felix console
Create OSGI bundle using BND with additional property
java -jar bnd.jar wrap -properties bundle.bnd {YourJarfile}.jar
bundle.bnd will look something like this
version=<Version>
Export-Package: <Package you want to export>
Private-Package: <Package you want to import>
Bundle-Version: 1
Bundle-Classpath: .,{yourjarfile}
More information of available options here http://fusesource.com/docs/esb/4.2/deploy_osgi/DeployJar-Convert.html
Option 4:
Using maven-bundle-plugin
1) Put your Jar file under /libs folder (using Web Dav) of your project and include it in project menifest or pom.xml
If you are using CRXDE then your bundle menifest will look like this. In this example, I assume that /libs folder is created at same level of your menifest file.
Export-Package: <Package you want to export, Use * for everything but not recommended>
Import-Package: *;resolution:=optional
Private-Package: <If you want>
Dynamic-Import: *
Embed-Dependency: *;scope=compile|runtime
Embed-Directory: /libs
Embed-Transitive: true
Your pom.xml will look like this
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<!-- You can use extension true to create fragment bundle -->
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Include-Resource>lib=${basedir}/lib</Include-Resource>
<Bundle-ClassPath>
.,
.... All non OSGI jar file
</Bundle-ClassPath>
<Fragment-Host>system.bundle; extension:=framework</Fragment-Host>
<Export-Package>
... Your comma seperated Export Package
</Export-Package>
<Import-Package>!*</Import-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Some more useful doc
http://www.cqblueprints.com/xwiki/bin/view/Blue+Prints/Deploying+3rd+Party+Libraries
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
A good example is http://www.wemblog.com/2012/03/how-to-integrate-soap-web-service.html
Feel free to let me know if missing something.