Fragment dependency on other fragments
Asked Answered
B

1

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

Bohner answered 6/9, 2011 at 2:40 Comment(0)
T
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.

Trigeminal answered 6/9, 2011 at 17:14 Comment(6)
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.Eliza
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.Trigeminal
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.Bohner
@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.Postmillennialism
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.Bohner
As workaround I have to add fragment A as project dependency of fragment B.Bohner

© 2022 - 2024 — McMap. All rights reserved.