How to create Dynamic Web Project using Bndtools OSGi Project.

594 views Asked by At

I Have Created a BndTools OSGi project that generates a .jar file.Now i want the BundleContext of that jar in my main project i.e. Dynamic Web Project (.war File). Dynamic web Project doesn't contain bnd.bnd file.So i can't inject that jar's dependency.

Are there any ways by which i can achieve this.

1

There are 1 answers

0
gamerson On

This can be accomplished two ways.

Quick and dirty way

  1. Create dynamic web project
  2. Right click web project > Choose Properties menu
  3. Click on Deployment Assembly
  4. Click Add
  5. Select Project for assembly directive type
  6. Select the bndtools project
  7. Repeat for 2nd project you want
  8. Deploy this web project to server or export war and notice that the output of the

Note this jar will only create the classes and no other resources that are usually created by the bnd.bnd file (e.g. correct Manifest, other included resources)

Better and more correct way

  1. Deploy the 2 jar files created by bndtools to some artifact repository local or public
  2. Create a new maven project using war packaging (e.g. default web project archetype)
  3. Specify these two bndtools project jars as dependencies
  4. Install the m2e-wtp plugin from its updatesite for Eclipse (which imports maven war projects and automagically creates eclipse dynamic web projects with all dependency references setup)
  5. Import the maven web project using File > Import > existing maven project
  6. During import the m2e-wtp project configurator will be activated and the necessary settings for including your 2 bndproject jars as dependencies will be correctly setup