To JAR a bundle or not to JAR, that is the question…
When you’re packaging bundles for deployment, 99.9% of the time you will want to have the bundle packaged into a single JAR. There are many reasons you would want to do this, whether it’s space savings or a way to combat that evil Windows path limitation. In Eclipse land, the way a bundle is packaged in a build was typically controlled at the feature level. In an Eclipse feature, you could declare a bundle and specify whether the bundle is needed to be unpacked or not (via the unpack attribute). If you had an Eclipse-based product that was simply bundle based, PDE Build had to make guesses on whether or not to pack the bundle or not. This was done using a simple algorithm, if the
Bundle-ClassPath header is present in your manifest and the classpath contains a ‘.’ (or is not defined, since ‘.’ is the default), then you will end up with a jar. This guessing can problematic for developers when you don’t want pack a bundle because of technical reasons.
So what’s the solution?
I have good news, in Eclipse 3.5 (starting with the 3.5M5 milestone), PDE supports the new
Eclipse-BundleShape header. This header simply has two values, “dir” or “jar,” which specify how the bundle should be packaged. This header is also used by p2 so when you go to publish your bundle in a repository, the metadata is properly generated.
In the end, we now have a solution that allows for a finer granularity in which a bundle’s packaging information can be specified.
I hope you find this information helpful!