This tutorial describes the purpose and usage of Eclipse fragment projects
A fragment is an optional attachment to another plug-in. This other plug-in is called the host plug-in. At runtime the fragment is merged with its host plug-in. Therefore, for the Equinox runtime, both projects are just one.
Fragments are always optional for their host plug-in and the host plug-in doesn’t even know that it exists.
The Eclipse IDE supports the creation of fragments via fragment projects. To create a fragment project select.
Fragments can be used to contain test classes. This way the tests can access the internal API of the plug-in classes and test it. Tests can also be contained in their own plug-in. In this case, they can only test the external API of other plug-ins.
Fragments are also used to contribute property files for additional translations. This allows you to contribute translation for a new language without the need to adjust other parts of the code.
In addition, fragments can also provide native code which is specific to certain operating systems (OS). In this case a platform filter is used to define that the fragment is only valid for a certain OS.
For example, the SWT user interface implementation of Eclipse uses this approach.
Last but not least, fragments can be used to contain resources like icon sets or other images. This allows you to customize your application icons via the provided fragment.
The following lists a fragment only valid for the Windows OS.
The OS is specified via the
Eclipse-PlatformFilter property and the
Fragment-Host makes this a fragment.
If you remove
Fragment-Host, the component is a regular plug-in again.
The available platforms filters are: * Eclipse-PlatformFilter: (osgi.ws=win32) * Eclipse-PlatformFilter: (osgi.ws=gtk) * Eclipse-PlatformFilter: (osgi.ws=cocoa)