Thursday, May 13, 2010

Features for Multi-OS Plugins

Assume you have a plugin for more than one, but not all platforms. One that may run on Windows and Linux, but not OS X. Assume it's called the "non_osx_tool" plugin, and the plugin's MANIFEST.MF contains a filter:

Eclipse-PlatformFilter: (| (osgi.os=linux) (osgi.os=win32))

Fine.

Now you switch to P2, and base your Product on Features. So there's a feature that lists this plugin. If you just list the plugin, then try to compile for all OS, all will look OK, but installation will fail on OS X because the feature requires the installation of the "non_osx_tool" plugin, which in turn declares itself unavailable for OS X.

You can specify in feature.xml that a plugin is OS-specific:

<plugin id="non_osx_tool" os="linux" ...

That way, the installation will work better because the feature will only trigger installation of the non_osx_tool on Linux. But you can only list one OS, Linux or Windows, not both.
I tried to use os="linux,win32" but that resulted in compiler errors The type ... cannot be resolved. It is indirectly referenced from required .class files referring to code in dependent plugins which were suddenly not found. Listing multiple architectures is either unsupported, or uses a format that I couldn't find.

Solution:
Create additional features "my_feature.win32" and "my_feature.linux". They each list the plugin for only win32 or linux, and the top-level feature then includes both these sub-features with a filter:

<includes
id="my_feature.linux"
version="0.0.0"
os="linux"/>
<includes
id="my_feature.win32"
version="0.0.0"
os="win32"/>

No comments:

Post a Comment