Tips and Tricks

Support for OSGi Declarative Services Annotations OSGi Declarative Services provide a powerful mechanism for developing complex, service-oriented applications. With proper tooling, annotations, which were added to Declarative Services in version 1.2, make it easy to generate and maintain the required component descriptor files.

When enabled, PDE automatically generates and updates Declarative Services component descriptor files from appropriately annotated Java source. This is done without requiring any additional builder to be configured in your project.

When you annotate your component implementation classes with @Component, and any reference bind methods with @Reference, PDE will validate your annotations and generate the corresponding component descriptor files. Any errors discovered during validation are highlighted and reported.

In addition, PDE also maintains the project's MANIFEST.MF and build.properties file -- generated component descriptor files are automatically added to the manifest and included in the build.

To enable this feature, go to Preferences or Project Properties > Plug-in Development > DS Annotations and check Generate descriptors from annotated sources.

Convert API Tools Javadoc tags to annotations Plug-ins using API Tools can add restrictions to API Java types (such as No Reference, No Extend) using Javadoc tags or annotations. It is recommended that projects use annotations, so PDE provides a conversion wizard that will replace the tags with the equivalent PDE annotations.

The wizard is available by right clicking on an API Tools enabled plug-in project and selecting Plug-in Tools > Convert API Tools Javadoc Tags.

A list of the available restrictions is available on the API Tools wiki page.

Show the current target platform in status bar If you regularly switch between target platforms, PDE provides an option to show the current target platform in the status bar. On the Plug-in Development preference page, select Show current target platform in status bar. The status bar entry will show the name of the active target definition and will show an error icon if there are problems with the target.
Find a feature by entering a plug-in name in the feature selection dialog When adding a feature to a product, feature or launch configuration, you can enter the name of a plug-in in the filter text box of the feature selection dialog. Features that include that plug-in will match the filter and be displayed.
Reload button in target editor In scenarios where the target editor is left in inconsistent state due to issues like unstable network connection and it is impossible to resolve the condition without manually editing the target editor file, you can use the Reload button in the Locations section of Target editor. It clears the cached p2 profile and then resolves the target.
Set default preference values for your product In order to set default preference values for your product, instead of manually adding the preferences to product's customization file, you can use the Convert Preferences wizard in the Customization section of your Product editor.
Create an API Baseline from a Target Definition To avail API tooling functionalities for any target definition, you can create an API Baseline in the Plug-in Development > API Baselines preference page.
Quickly search for any plug-in artifact Use the Open Plug-in Artifact dialog to quickly find and open plug-in artifacts. Search by the name of the plug-in, feature or product, or search for a specific package, extension point or extension. The icons can be used to see whether the artifact is available in the workspace or if it comes from the target platform. You can press Ctrl-Shift-A to open the dialog.
To clean or not to clean When you create a new runtime workbench launch configuration, PDE presets the Program Arguments on the launch configuration to include a -clean argument. 

This -clean argument clears all runtime-cached data in your runtime workbench from one invocation to the next to ensure that all the changes made in your host workbench, e.g. new Java packages were added to a plug-in project, etc., are picked up when you launch a runtime workbench.

This clearing of the cache may hinder performance if your target platform contains a large number of plug-ins. 

Therefore, if you're in a situation where your target platform has a large number of plug-ins and you're at a stage where you are not actively adding/removing packages from your plug-in projects, you could remove the -clean argument from the launch configuration to improve startup time.

Importing with linking Importing external plug-ins and fragments can be time consuming and may result in large workspaces, depending on the content of the plug-ins being imported.  Therefore, the 'Import External Plug-ins and Fragments' wizard gives you the option to import with linking.  This means that the import operation will not copy the resources being imported into your workspace.  It will simply create links to the files being imported.  You will be able to browse these linked resources, as if they had been copied into your workspace.  However, they are physically not there on your file system, so you will not be able to modify them.  Beware of operations that depend on files being physically in your workspace, as they will not work on linked resources.
Templates For a quick start, PDE provides several template plug-ins that will generate a plug-in with one or more fully-working extensions.  In addition, if at any point, you would like to add a new extension from the template list (without having to generate a plug-in), you could access these extension templates directly from the manifest editor.  From the 'Extensions' page of the editor, click 'Add...'.  In the wizard that comes up, select Extension Templates in the left pane and choose the template of choice in the right pane.
Plug-in dependency extent If you have ever looked at the list of plug-ins that your plug-in depends on and wondered why your plug-in needs a particular plug-in X, now you can easily find out why. 

The Compute Dependency Extent operation found on the context menu in several contexts (including manifest file Dependencies page and Plug-in Dependencies view) performs a combined Java and plug-in search to find all Java types and extension points provided by plug-in X which are referenced by your plug-in. The results will be displayed in the Search view.  When a type is selected in the Search results view, the References in MyPlugIn action in the context menu searches for the places in the plug-in where the selected type is referenced. 

If the search returns 0 results, you should definitely remove plug-in X from your list of dependencies, as it is not being used at all, and it would just slow class loading.

The Compute Dependency Extent is also useful to check if you are using internal (non-API) classes from plug-in X, which might not be desirable.

Finding unused dependencies Minimizing a plug-in's number of dependencies is certain to improve performance.  As your plug-in evolves, its list of dependencies might become stale, as it might be still containing references to plug-ins that it no longer needs.  A quick way to check that all dependencies listed by your plug-in are actually used by the plug-in is to run the 'Find Unused Dependencies' utility, which is available through the context menu of the 'Dependencies' page of PDE's manifest editor.
Extending the Java search scope Java Search is limited to projects in your workspace and external jars that these projects reference.  If you would like to add more libraries from external plug-ins into the search: open the Plug-ins View, select a plug-in and choose Add to Java Search from the context menu. This is handy for remaining aware of other plug-ins that depend on ones you're working on.

On the Plug-in Development preference page you can also turn on Include all plug-ins from target in Java search, which will add every plug-in in your target platform to the search scope.

Creating a Rich Client Application The Open the RCP cheat sheetCreating a Rich Client Application cheat sheet will guide you through the individual steps to create a plug-in, define a plug-in based product, customize a product, export a Rich Client Platform (RCP) application and define a feature-based product using the Plug-in Development Environment (PDE).
Creating an Eclipse Plug-in The Open the hello world cheat sheetCreating an Eclipse Plug-in cheat sheet will guide you through the individual steps to create a plug-in, a plug-in extension, a feature and an update site using the Plug-in Development Environment (PDE). It will also demonstrate how to install and uninstall a feature using Install/Update.