2

I have a requirement to design a plugin which is OS specific. Depending on OS (MAC or Windows), the content of the plugin will vary.

Currently we are maintaining two different plugins, one for Windows and other for MAC, plugin id's com.core.win and com.core.mac.

My main plugin is dependent on above plugin. But as my plugin ID is different depending on OS, both the plugins are added in Plug-ins Dependency as "Optional".

com.core.win; resolution:=optional,
com.core.mac; resolution:=optional

But in reality the dependency is a must, "Required". How do I design my plugin structure, such that a tight dependency can be defined ? Is there any standard solution approach ?

Thank You!

Priyadarshini
  • 129
  • 1
  • 10

1 Answers1

2

Usually you have one base plugin with a platform specific fragment for each platform.

You use the Eclipse-PlatformFilter MANIFEST.MF entry to specify the platform, something like:

Eclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx) (osgi.arch=x86_64) )

which specifies the Cocoa window system, Mac OS X operating system and 64 bit (this is the normal setting for current Macs).

In the plugin.xml/MANIFEST.MF editor this is the 'Platform Filter' field in the 'General Information' section of the 'Overview' tab.

Here is a good introduction about fragments, the Eclipse PDE Help also has documentation. Also, SWT is a good example of usage of fragments for platform-specific code. See this FAQ entry to learn how to get the SWT code for inspection (you don't need to actually do the build and export part).

E-Riz
  • 31,431
  • 9
  • 97
  • 134
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thanks @greg for answering. I am very new to fragment concept. Could you please explain me the hierarchy/structure, considering the example I have stated. ? Also what changes need to be done for update site to work ? – Priyadarshini Aug 26 '16 at 13:27
  • I added some links in the answer. – E-Riz Aug 26 '16 at 13:37
  • This is getting too broad for a Stack Overflow answer. The Eclipse Plug-in Development Environment Guide has info on fragments, there is also [this](https://wiki.eclipse.org/FAQ_What_is_a_plug-in_fragment%3F) and [this](http://www.vogella.com/tutorials/EclipseFragmentProject/article.html) and many other articles. – greg-449 Aug 26 '16 at 13:39
  • Hi Greg, In development env, Platform.getFragments(hostBundleInstance) is returning all available fragments. But in an runtime installer setup, Platform.getFragments() is returning null. Both fragment and host plugins are present in dropins folder. What am I missing here ? – Priyadarshini Aug 31 '16 at 11:22
  • @greg-449 I just stumbled upon this answer because I have a similar problem. IMHO, your answer does not answer the question because you (and the links you provided) only explained how to make fragments platform-specific, but not how to use them in a plugin. Furthermore, you claimed "SWT is a good example of usage of fragments for platform-specific code" although the blog post linked in the sentence before claims that SWT is an example of how not to use fragments. I'd really appreciate an answer to the original question but I don't want to ask a new one because it hasn't been answered yet IMO. – danzel Oct 25 '18 at 19:01