5

I have a plugin which is the host of fragment A & B. I export a package using Export-Package header from fragment A. Hopefully I can import that package in fragment B using Import-Package header. But the PDE reports that the dependency is unresolved. Is it possible at all using this scenario ? The following post http://www.eclipse.org/forums/index.php/t/238204/ confirms that it is.

Any help would be greatly appreciated.

Thanks & Regards,

Setya

SetNug
  • 331
  • 1
  • 2
  • 13

1 Answers1

13

The scenario described is perfectly possible in runtime, however PDE is not aware of the dependency at build time. You need to add the header Eclipse-ExtensibleAPI: true to the host bundle of fragment A.

To reiterate, this header is only used at build time by PDE and is not an OSGi header.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • Isn't this somewhat of an abuse of fragments? I don't think fragments "should" export anything, since nothing else should have dependencies on them. Their existence in a system should not be relied upon by other bundles. I wholly admit I could be wrong, based on my limited understanding of what a fragment is supposed to be used for. – Robin Sep 07 '11 at 16:09
  • 1
    No it's not, IMHO. Remember, other bundles don't have a dependency on the fragment, they have a dependency on the package. They shouldn't care which bundle the package comes from, or whether the package comes from a fragment. It's certainly possible for fragments to be abused but the OP didn't specify *why* he was using a fragment in this instance. – Neil Bartlett Sep 07 '11 at 17:09
  • I'm glad if it is in fact possible to do that. I'll try the header you suggested & will get back with the result. To complete my story, fragment A & B are needed only in development time since they exist only for testing purposes. Initially fragment A was a bundle, but because I had the same thought that, if possible, fragment B shouldn't depend on a bundle, then I convert the bundle into fragment A & faced the problem I posted. – SetNug Sep 09 '11 at 04:27
  • @user589207 I hit this problem a few months back and Neil is right, you do need it. There is a lot of history in eclipse about this. – Alasdair Sep 12 '11 at 21:34
  • I've added the header as Neil suggested. Now from fragment B, when I add 'Imported Packages' I can see packages exported by fragment A, but still after I add those packages, any classes from those packages that I use in fragment B are marked unresolvable. – SetNug Oct 05 '11 at 05:03
  • As workaround I have to add fragment A as project dependency of fragment B. – SetNug Oct 31 '11 at 15:46