Skip to main content



      Home
Home » Eclipse Projects » Equinox » Struggling with converting lib jar to bundle
Struggling with converting lib jar to bundle [message #77560] Fri, 17 November 2006 17:59 Go to next message
Eclipse UserFriend
Originally posted by: bill.kayser.ca.com

I want to convert the apache collections library to a plug-in project
whose bundle can still be used as a library by non-osgi clients.

I imported the jar file into the new plug-in project so the classpath is
at the root of the project--the "org" folder is in the root directory.

When I set up the manifest to find classes in the root directory I have
two problems:
1) The IDE does not add the classes to the project classpath.
2) The PDE build does not resolve the classes.

However when I export the project as a plug-in and put that in the
plug-ins directory of the base, the PDE build finds the classes and
everything compiles okay.

I can solve (1) by adding the root directory to the libraries in the
java build path of the project.

But (2) has me stumped.

Am I taking the wrong approach? If I just embed the collections jar
file in the bundle and add it to the classpath, everything works fine.
But then I can't use it as a regular jar library.

Here is my manifest:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Commons Collections Plug-in
Bundle-Category: lib
Bundle-Description: Repackaged Apache Commons Collections
Bundle-SymbolicName: org.apache.commons_collections
Bundle-Version: 3.0.0
Bundle-Localization: plugin
Export-Package: org.apache.commons.collections,
org.apache.commons.collections.bag,
org.apache.commons.collections.bidimap,
org.apache.commons.collections.buffer,
org.apache.commons.collections.collection,
org.apache.commons.collections.comparators,
org.apache.commons.collections.functors,
org.apache.commons.collections.iterators,
org.apache.commons.collections.keyvalue,
org.apache.commons.collections.list,
org.apache.commons.collections.map,
org.apache.commons.collections.set
Bundle-Vendor: Apache Foundation
Eclipse-LazyStart: true
Bundle-ClassPath: .

I've tried lots of different things in the build.properties but nothing
fixes the problem.

Bill
Re: Struggling with converting lib jar to bundle [message #77576 is a reply to message #77560] Fri, 17 November 2006 19:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: slewis.composent.com

Hi Bill,

Bill Kayser wrote:
> I want to convert the apache collections library to a plug-in project
> whose bundle can still be used as a library by non-osgi clients.
>
> I imported the jar file into the new plug-in project so the classpath is
> at the root of the project--the "org" folder is in the root directory.
>
> When I set up the manifest to find classes in the root directory I have
> two problems:
> 1) The IDE does not add the classes to the project classpath.
> 2) The PDE build does not resolve the classes.

The PDE builder (only) gets invoked when the .project file has the
following under <buildSpec> and <natures> (in addition to the usual
things for java projects):

<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>


>
> However when I export the project as a plug-in and put that in the
> plug-ins directory of the base, the PDE build finds the classes and
> everything compiles okay.
>
> I can solve (1) by adding the root directory to the libraries in the
> java build path of the project.
>
> But (2) has me stumped.
>
> Am I taking the wrong approach? If I just embed the collections jar
> file in the bundle and add it to the classpath, everything works fine.
> But then I can't use it as a regular jar library.


I think an easier approach is to just create a regular java project, set
things up the way you want in terms of location of classes from jar and
classpath set to project dir, etc., and then open the context menu for
the project and choose PDE Tools -> Convert Projects to Plugin
Projects... It will then create the manifest.mf for you and make
changes to the .project and .classpath appropriately.

I think you need to worry about including the info from the apache
META-INF directory in with the new Manifest.mf though for licensing, etc.

Scott
Re: Struggling with converting lib jar to bundle [message #77590 is a reply to message #77560] Sat, 18 November 2006 05:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Are you sure it's a PDE project? It sounds like an ordinary Java project.

There's a wizard (new PDE project from Jar) that you could use to do the import; that should set everything up.

Or, you could use Peter Krien's BND tool which takes an existing Jar and 'upgrades' it to be bundle-compatible:

http://www.aqute.biz/Code/Bnd

Alex.
Re: Struggling with converting lib jar to bundle [message #77625 is a reply to message #77560] Sat, 18 November 2006 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com

Consider using the PDE wizard as detailed at
http://wiki.eclipse.org/index.php/Adding_Bundles_To_Orbit#ad dingLibrary
This should do all the work for you.

Jeff

Bill Kayser wrote:
> I want to convert the apache collections library to a plug-in project
> whose bundle can still be used as a library by non-osgi clients.
>
> I imported the jar file into the new plug-in project so the classpath is
> at the root of the project--the "org" folder is in the root directory.
>
> When I set up the manifest to find classes in the root directory I have
> two problems:
> 1) The IDE does not add the classes to the project classpath.
> 2) The PDE build does not resolve the classes.
>
> However when I export the project as a plug-in and put that in the
> plug-ins directory of the base, the PDE build finds the classes and
> everything compiles okay.
>
> I can solve (1) by adding the root directory to the libraries in the
> java build path of the project.
>
> But (2) has me stumped.
>
> Am I taking the wrong approach? If I just embed the collections jar
> file in the bundle and add it to the classpath, everything works fine.
> But then I can't use it as a regular jar library.
>
> Here is my manifest:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Commons Collections Plug-in
> Bundle-Category: lib
> Bundle-Description: Repackaged Apache Commons Collections
> Bundle-SymbolicName: org.apache.commons_collections
> Bundle-Version: 3.0.0
> Bundle-Localization: plugin
> Export-Package: org.apache.commons.collections,
> org.apache.commons.collections.bag,
> org.apache.commons.collections.bidimap,
> org.apache.commons.collections.buffer,
> org.apache.commons.collections.collection,
> org.apache.commons.collections.comparators,
> org.apache.commons.collections.functors,
> org.apache.commons.collections.iterators,
> org.apache.commons.collections.keyvalue,
> org.apache.commons.collections.list,
> org.apache.commons.collections.map,
> org.apache.commons.collections.set
> Bundle-Vendor: Apache Foundation
> Eclipse-LazyStart: true
> Bundle-ClassPath: .
>
> I've tried lots of different things in the build.properties but nothing
> fixes the problem.
>
> Bill
Re: Struggling with converting lib jar to bundle [message #77733 is a reply to message #77625] Mon, 20 November 2006 16:20 Go to previous message
Eclipse UserFriend
Originally posted by: bill.kayser.ca.com

Thanks for all the suggestions. Using the PDE Wizard worked perfectly.
That BND tool will be useful also.

Bill

Jeff McAffer wrote:
> Consider using the PDE wizard as detailed at
> http://wiki.eclipse.org/index.php/Adding_Bundles_To_Orbit#ad dingLibrary
> This should do all the work for you.
>
> Jeff
>
Previous Topic:Jobs API
Next Topic:logging in eclipse
Goto Forum:
  


Current Time: Mon May 12 07:55:03 EDT 2025

Powered by FUDForum. Page generated in 0.09717 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top