Take a look at the Orbit wiki (http://wiki.eclipse.org/index.php/Orbit).
Orbit is a project designed to be a repository for third party libraries
that are approved for use in Eclipse projects. The wiki documents
many of the best practices that Eclipse developers use to package 3rd party
code for use in Eclipse projects. In particular see http://wiki.eclipse.org/index.php/Adding_Bundles_to_Orbit#Adding_a_library_for_the_first_time
Orbit developers generally extract the
contents of the third party jar into the root of a bundle and use '.' for
the Bundle-ClassPath. This has the following advantages.
- Embedded jars are extracted from jar'ed
bundles at runtime because it is expensive to load files from embedded
jars. This requires more disk space.
- For deployment, jar'ed bundles are
preferred. Directory style bundles are not OSGi standard and may
not work on other frameworks.
- Embedded jars in jar'ed bundles are
not supported by JDT/PDE for project classpaths. JDT only understands
simple jars or directories.
<osgi@xxxxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
05/09/2007 07:58 AM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
"Equinox development mailing list"
RE: [equinox-dev] How can I embed a
JAR in a plugin?
Thank you! That completely answers my question.
You mentioned two ways to do this:
- extract the contents (i.e. class files) of thirdparty.jar into a
folder in the bundle's ".", or
- keep the jar intact, but use a directory structure instead of
a jar file (which contains thirdparty.jar)
What is the "usual" or "best" practice?
> -----Original Message-----
> From: Jeremy Volkman [mailto:jvolkman@xxxxxxxxx]
> Sent: 9 May 2007 19:35
> To: osgi@xxxxxxxxxxx; Equinox development mailing list
> Subject: Re: [equinox-dev] How can I embed a JAR in a plugin?
> If I understand your problem correctly, you're trying to include this
> third party jar in your Eclipse target platform so that it can be
> by plugin projects in your workspace. If this is the case, you're
> running into the fact that Eclipse PDE doesn't support developing
> against bundles with embedded jars. This is not Equinox's problem,
> but rather a side effect of PDE being dependent upon the JDT, and
> JDT's inability to find a class that's within an embedded jar.
> To put a bundle with an embedded jar in your target platform, simply
> extract it. E.g., if your bundle was "com.somecompany.mybundle.jar",
> you'd extract it to a directory called "com.somecompany.mybundle"
> inside your plugins directory. You can see that many of the
> plugins are distributed like this.
> Another thing to note is that you can change the PDE target platform
> directory to something other than the Eclipse plugins directory. This
> allows you full control over which bundles are available to your
> workspace bundles and removes all the distributed Eclipse bundle
> exports. The option is under Preferences -> Plug-in Development
> Target Platform. This of course is not what you want if you're
> developing an Eclipse plugin. :)
> Hope that helps,
> On 5/9/07, David Leangen <osgi@xxxxxxxxxxx> wrote:
> > Since many OSS projects do not package their code as osgi bundles,
> > had to create my own bundles from time to time.
> > This time, I thought that rather than including it as a project
> > Eclipse environment, I'll put the bundle in my plugins directory.
> > However, I have not yet been able to figure out how to expose
> > classpath of the embedded jar file to my projects in the workspace.
> > If I directly compile the code (thus all the class files are
in "." in
> > the bundle rather than in a jar in the bundle), I can include
> > this way without any problems.
> > I thought that I only needed to include the jar in the Bundle-ClassPath
> > entry in the manifest, but Equinox does not recognize this.
> > What does Equinox require that I do to expose this embedded jar
> > projects in Eclipse via my plugin bundle?
> > Thank you!
> > David
> > _______________________________________________
> > equinox-dev mailing list
> > equinox-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/equinox-dev
equinox-dev mailing list