I'm trying to wrap a number of jars as bundles that I want other bundles to be able to depend on. With Spring dm Server, this used to be as simple as adding a jar file to a new bundle project, exporting all the classes, and ensuring the jar file was on the build and class paths.
Here's a simple, canonical example of what I'm trying to do (and where I'm failing):
Take, for instance, Joda Time, I'd like this in a bundle so I can share it as a dependency. First, I create a bundle to hold the jar:
- Create a new bundle project Eclipse (Indigo Java EE)
- Create a folder "lib" in the project root
- Add joda-time-1.6.1.jar to the "lib" folder
- Add lib/joda-time-1.6.1.jar to the build path
Update src/META-INF/MANIFEST.MF to export all of the classes:
Manifest-Version: 1.0 Bundle-Version: 1.0.0 Bundle-Name: joda-time Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.joda.time Bundle-ClassPath: lib/joda-time-1.6.1.jar, . Export-Package: org.joda.time, org.joda.time.base, org.joda.time.chrono, org.joda.time.convert, org.joda.time.field, org.joda.time.format, org.joda.time.tz
Now, we want to use this in some new bundle we've created:
- Create a new bundle project in Eclipse (Indigo Java EE) "MyDepTest"
Edit src/META-INF/MANIFEST.MF to import org.joda.time:
Manifest-Version: 1.0 Bundle-Version: 1.0.0 Bundle-Name: MyDepTest Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.foo.deptest Import-Package: org.joda.time Import-Bundle: org.joda.time;version="[1.0.0,1.0.0]"
Add the org.joda.time bundle to the project references so Eclipse can resolve the depenencies
Write the class:
package com.foo.deptest; import org.joda.time.DateTime; public class SimpleDepTest { public SimpleDepTest (){ DateTime dt = new DateTime(); } }
Now, org.joda.time.DateTime
should resolve, but Eclipse indicates the following error with a red underline on org.joda
The import org.joda cannot be resolved
Where have I gone wrong? How do I wrap a jar as a bundle so that I can use the classes in other bundles?