views:

40

answers:

2

I have the following setup:

  • eclipse
  • a standard Java project (A)
  • an eclipse plugin project (B)

How (if possible) can I use packages from A within B without first compiling a JAR file from A and adding it to B?

Thanks!

A: 

if you declare:

  • a project with sources from A
    ("New" Java Project / "Create a Java Project" / "create project from existing source")
  • a second project with:
    • sources from B
    • project dependency including "projectA"

you will get just what you need.
(a compilation -- of sources from A -- is still needed, but no jarA needs to be produced)

VonC
If I do this, I am getting "Package 'bla' does not exist in this plugin" errors in my MANIFEST.MF when trying to export packages from Project A
Joscha
@Joscha: did you add the needed dependencies and/or (in your case), the required packages in your plugin.xml (through the plug-in.xml editor page)? see http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tools/editors/manifest_editor/dependencies.htm
VonC
actually yes, but that didn't help - I am now using the "Link Source" mechanism from eclipse - that seems to work just fine, but the setup is pretty hacky...
Joscha
@Joscha: do you mean "using a linked folder"? (http://stackoverflow.com/questions/1470827/external-output-folder-in-eclipse/1470833#1470833)
VonC
I think it is something similar: Project Properties -> java Build Path -> Source -> Button "Link Source"
Joscha
A: 

The java project A needs to be known from OSGi/Eclipse in order to be accessible at design time (ie while in eclipse, including launch and debugging) and then at runtime. The correct approach would be to make A an OSGI bundle, and reference this in B:

  • select A, right-click, project, pde tools, convert to plugins project ...

  • then in B, open the manifest.mf and add (com.example.pack being some packages defined in A that you want to use in B): Import-Package: com.example.pack

Philippe Ombredanne