Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

FAQ How do I make my plug-in connect to other plug-ins?

Like members of a community, plug-ins do not generally live in isolation. Most plug-ins make use of services provided by other plug-ins, and many, in turn, offer services that other plug-ins can consume. Some groups of plug-ins are tightly related, such as the group of plug-ins providing Java development tools—the JDT plug-ins—and other plug-ins, such as SWT, stand alone without any awareness of the plug-ins around them. Plug-ins can also expose a means for other plug-ins to customize the functionality they offer, just as a handheld drill has an opening that allows you to insert other attachments such as screwdrivers and sanders. When designing a plug-in, you need to think about what specific plug-ins or services it will need, what it will expose to others, and in what ways it wants to allow itself to be customized by others.



To rephrase all this in Eclipse terminology, plug-ins define their interactions with other plug-ins in a number of ways. First, a plug-in can specify what other plug-ins it requires, those that it absolutely cannot live without. A UI plug-in will probably require the SWT plug-in, and a Java development tool will usually require one or more of the JDT plug-ins. Plug-in requirements are specified in the plug-in manifest file (plugin.xml). The following example shows a plug-in that requires only the JFace and SWT plug-ins:

   <requires>
      <import plugin="org.eclipse.jface"/>
      <import plugin="org.eclipse.swt"/>
   </requires>

Your plug-in can reference only the classes and interfaces of plug-ins it requires. Attempts to reference classes in other plug-ins will fail.



Conversely, a plug-in can choose which classes and interfaces it wants to expose to other plug-ins. Your plug-in manifest must declare what libraries (JARs) it provides and, optionally, what classes it wants other plug-ins to be able to reference. This example declares a single JAR file and exposes classes only in packages starting with the prefix com.xyz.*:

  <runtime>
    <library name="sample.jar">
      <export name="com.xyz.*"/>
    </library>   
  </runtime>



Finally, a plug-in manifest can specify ways that it can be customized (extension points) and ways that it customizes the behavior of other plug-ins (extensions).




See Also:

[[FAQ_What_is_the_plug-in_manifest_file_%28%3Ctt%3Eplugin.xml%3C%2Ftt%3E%29%3F]]


FAQ_What_are_extensions_and_extension_points?


FAQ_What_is_the_classpath_of_a_plug-in?


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top