views:

64

answers:

1

I have never worked with plug-in fragments before. I thought that by creating a new class within a fragment and exporting the package that contains it in the fragment's manifest, I'd be able to access that class from another plug-in that already has a dependency on the host plug-in. However, I cannot seem to make this work. Are the contents of a fragment ever visible to any plug-in besides the host plug-in? If so, is there something special I have to do to allow this?

+2  A: 

The problem is not, that the contents of the fragment aren't visible to another plugin: They are - just try loading e.g. a properties file from the classpath, it still works if that properties file is provided by the fragment.

But what you don't have, is compile-time information about the fragment's contents. That's the principle of a fragment: You can't have a dependency on it. And you don't know, if somebody has fragments installed or not.

It's also not only a problem that just "any plug-in besides the host plug-in" has. It's a problem, that even the host-plugin itself has. It doesn't know about the fragment's existence at compile-time.

You also can't reliably use a fragment to override parts of the host plug-in's classes: http://wiki.eclipse.org/FAQ_Can_fragments_be_used_to_patch_a_plug-in%3F , if that's what you want to do. The page also describes, how it can be done.

Hope this helps.

Chris Lercher
Thanks much. This all makes perfect sense to me now that it's spelled out -- I should have realized that even the host plug-in cannot use any information about its fragments at compile time. I was originally curious about fragments because I wanted to include test code in them. The inability for test code to be accessed outside the fragment is actually a nice benefit.
Mike Daniels