Plug-ins and fragments

Features are described in terms of the plug-ins that comprise them. A plug-in is used to group your code into a modular, extendable and sharable unit.

Plug-ins are modular as each plug-in contains some portion of code. The plug-in specifies other plug-ins (or java packages) it requires to be available to run and it also specifies the set of java packages it provides. An Eclipse based product will contain multiple plug-ins, which can be added, replaced or removed to alter the functionality of the program.

Eclipse plug-ins are based on OSGi bundles. OSGi is used to manage the plug-ins in a product. A plug-in must contain a manifest file with valid OSGi headers for plug-in name and version.

Plug-ins are extendable using extensions and extension points. A plug-in can provide one or more extension points so other plug-ins can add to the functionality of the plug-in. A plug-in may also provide extensions to connect to other plug-ins. To use extensions you must provide a plugin.xml file.

A fragment is used to replace or extend the functionality of an existing plug-in. A common use for fragments is to put environment (operating system, architecture, etc.) specific code into fragments. Depending on the environment the plug-in is installed in the base plug-in code along with the correct fragment can be installed. Fragments are also ideal for shipping features like language or maintenance packs that typically trail the initial products for a few months.

When a fragment is detected by the platform and its parent plug-in is found, the fragment's libraries, extensions and extension points are "merged" with those of the parent plug-in. While this merging mechanism is good from a runtime point of view, developers need to view fragments as separate entities while working on them. Fragments require a valid OSGi manifest. To use extensions and extension points they must define a fragment.xml file which has the same structure as a plugin.xml file.

Plug-ins and fragments can be packaged in Plug-in archive files