Search code examples
mavenosgitychocglib

How to add cglib to a OSGI manifest of RCP client?


I want to use cglib in an RCP client. The RCP client is build using maven and the tycho plugin. We are useing a manifest first strategy.

This is my MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: INFO+ RCP Common UI Plug-in
Bundle-SymbolicName: a.company.prj.rcp.common.ui
Bundle-Version: 8.0.14.qualifier
Bundle-Vendor: Schweizerische Bundesbahnen SBB
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: a.company.prj.rcp.common.ui.CommonUIPlugin
Bundle-ActivationPolicy: lazy
Export-Package: 
 a.company.prj.rcp.common.ui,
 ...
 a.company.prj.rcp.common.ui.wizards.page
Import-Package: 
 org.apache.log4j;version="1.2.17"
Require-Bundle: 
 org.eclipse.ui;bundle-version="3.7.0",
 org.eclipse.ui.forms;bundle-version="3.5.101",
 com.ibm.ws.jpa.thinclient;bundle-version="8.0.6",
 ...
 a.company.prj.rcp.core;bundle-version="8.0.14",
 ...

To add cglib I changed the Import-Package section to:

Import-Package: 
 net.sf.cglib;version="3.2.0",
 org.apache.log4j;version="1.2.17"

Now Eclipse complains with:

No available bundle exports package 'net.sf.cglib'

Ayn ideas how to include cglib with this environment?


Solution

  • You will need to add the cglib bundle to your target platform, i.e., the set of all bundles Tycho will consider when resolving dependencies. You have three options to do so (taken from the Tycho wiki page on this topic):

    1. You can simply add an entire p2 repository to your target platform.
    2. You can use a .target file and reference the cglib bundle therein (as already suggested by stempler).
    3. You can declare a Maven <dependency> on cglib and make Tycho “consider” it.

    As you already have a working Tycho build, I suggest you use whatever option you or your colleagues have used in the build before.

    One more note: Options 1 and 2 require that the cglib bundle is available in a p2 repository, whereas option 3 works even if the bundle comes from a “normal” Maven repository like the Central Repository. But in all three cases the cglib JAR must be a valid OSGi bundle, i.e., include an OSGi MANIFEST.MF with Bundle-SymbolicName etc.