Home » Eclipse Projects » Plugin Development Environment (PDE) » Exposing packages from a jar inside a plug-in
Exposing packages from a jar inside a plug-in [message #667475] |
Thu, 28 April 2011 20:02  |
Eclipse User |
|
|
|
Moved this topic from the PDE news group to here.
We have two plug-in A and B where B is the core plug-in which provide the main business logic. There are several library jars inside plugin B (B imported them). Let's say one jar has a package called a.b.c. In the plug-in.xml file of B we exposed the package a.b.c. Plugin A requires plug-in B and needs to refer to the classes in the package a.b.c. We tried two approaches:
1. In the plug-in.xml dependencies section of A, we added B. into the "Required Plug-ins". However, in a class in A, when we tried to import a class in package a.b.c, we got a java compiler error saying package a.b.c can not be solved.
2. In the plug-in.xml dependencies section of A, we added a.b.c into the "Imported Packages" (it showed up there). But still got the same error as the first approach.
Any idea what is wrong?
Thanks.
|
|
| |
Re: Exposing packages from a jar inside a plug-in [message #668202 is a reply to message #667475] |
Wed, 04 May 2011 09:36   |
Eclipse User |
|
|
|
Sorry for later reply.
Manifest of A looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: XXXXXX
Bundle-SymbolicName: A
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: XXXXXX
Require-Bundle: B,
......
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Research In Motion Limited
Export-Package: net.rim.ajde.external
Bundle-ClassPath: apache-mime4j-0.6.jar,
httpclient-4.0.3.jar,
httpcore-4.0.1.jar,
httpmime-4.0.3.jar,
.
Manifest of B looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: B
Bundle-SymbolicName: XXXXXXXX;singleton:=true
Bundle-Version: 11.0.0.qualifier
Bundle-Activator: XXXXXXXXXX
Bundle-Vendor: XXXXXXXXX
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
......
Bundle-ActivationPolicy: lazy
Export-Package: a.b.c,
......
Bundle-ClassPath: .,
libs/lib.jar,
Thanks.
|
|
| |
Re: Exposing packages from a jar inside a plug-in [message #668234 is a reply to message #668202] |
Wed, 04 May 2011 11:31   |
Eclipse User |
|
|
|
On 05/04/2011 09:36 AM, Raymond wrote:
> Sorry for later reply.
> Manifest of A looks like:
> Require-Bundle: B,
> Manifest of B looks like:
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: B
> Bundle-SymbolicName: XXXXXXXX;singleton:=true
> Bundle-ActivationPolicy: lazy
> Export-Package: a.b.c,
> .....
> Bundle-ClassPath: .,
> libs/lib.jar,
I'll assume you matched your Require-Bundle: B to the real
Bundle-SymbolicName provided in B (your example, XXXXXXX :-)
That's all that is needed.
I created a plugin z.ex.jars.b with the following:
Bundle-ClassPath: libs/version_1.0.0.jar,
.
Export-Package: ex
Then a plugin z.ex.jars.a with:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
z.ex.jars.b;bundle-version="1.0.0"
I was able to import ex.Version (from z.ex.jars.b) into
z.ex.jars.a.Activator with no problems.
Is your plugin B in your target platform (which might still be effected
by the problem Martin mentioned) or are they both in your workspace.
If they're both in your workspace, can you go to your plugin B project,
right click, and use PDE Tools>Update Classpath to make sure your
classpath is correct?
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
|
Re: Exposing packages from a jar inside a plug-in [message #668387 is a reply to message #667475] |
Thu, 05 May 2011 10:03   |
Eclipse User |
|
|
|
I figured out the problem yesterday but not sure if it is an expected behavior or not. In the Bundle-ClassPath of plugin A actually looks like below ( I missed lib1.jar in my previous post):
Bundle-ClassPath: apache-mime4j-0.6.jar,
httpclient-4.0.3.jar,
httpcore-4.0.1.jar,
httpmime-4.0.3.jar,
lib1.jar
lib1.jar is a command line tool jar which requires those apache and http jars. So that in the manifest file of lib.jar, it claims:
Class-Path: ., apache-mime4j-0.6.jar,httpclient-4.0.3.jar,httpcore-4.0.1.ja r,httpmime-4.0.3.jar
This Class-Path definition seemed to ruin the classpath of plug-in A. I also noticed some resource folder of A was not shown in the package explore view. I manually remove this Class-Path element from the manifest of lib1.jar and refresh plug-in A, everything got back to normal. The classes in the exposed package from B can be seen in A and those disappeared resource folder were also back.
So, do you think this is an expected behavior?
Thanks.
|
|
| | |
Re: Exposing packages from a jar inside a plug-in [message #671336 is a reply to message #667475] |
Tue, 17 May 2011 10:52  |
Eclipse User |
|
|
|
Paul, the problem was not solved actually. Yes, the classpath entry in the manifest in the lib1.jar did ruined the classpath of the plug-in but that's not all. I got it work because I incidentally imported plug-in B into the same workspace as A. If I did not import B but installed B into the eclipse I was using, A still could not see the packages exposed by B. Also, in you test case
"I created a plugin z.ex.jars.b with the following:
Bundle-ClassPath: libs/version_1.0.0.jar,
.
Export-Package: ex"
Did you try to make z.ex.jars.b a jar; install it into eclipse and used it in A?
I think what Martin said "I remember that this was an issue with packed plug-ins. The compiler did not recognize the jars in bundle B unless this is deployed as a folder, not a jar." makes sense. Has this bug been fixed?
Thanks.
|
|
|
Goto Forum:
Current Time: Wed Jul 23 01:47:03 EDT 2025
Powered by FUDForum. Page generated in 0.09889 seconds
|