FAQ Why should I add my own project nature?
Project natures act as tags on a project to indicate that a certain tool is used to operate on that project. They can also be used to distinguish projects that your plug-in is interested in from the rest of the projects in the workspace. For example, natures can be used to filter declarative extensions that operate only on projects of a particular type. The propertyPages and popupMenus extension points allow you to filter enablement of an extension, based on various properties of the selected resource. One of the properties that this mechanism understands is the nature of a project. Here is an example of an actionSet declaration that operates only on files in projects with the PDE nature:
<extension point="org.eclipse.ui.popupMenus"> <objectContribution objectClass="org.eclipse.core.resources.IFile" id="org.eclipse.pde.ui.featureToolSet"> <filter name="projectNature" value="org.eclipse.pde.FeatureNature"> </filter> ...
Another reason for using natures is to make use of the nature lifecycle methods when your plug-in is connected to or disconnected from a project. When a nature is added to a project for the first time, the nature’s configure method is called. When the nature is removed from the project, the deconfigure method is called. This is an opportunity to initialize metadata on the project and to associate additional attributes, such as builders, with the project.
(As a plugin developer this nature bit is quite confusing. The only place I found that one can see the "natures" on a project is the .project file. Only after watching the contents of this file as I added nature to my projects did I get it to work. I started by added builders directly to projects, but the results where inconsistent: sometimes they added, sometimes not. Once I got nature-addtion and removal to work and set builders in the configure/deconfigure methods of my plugin nature, then things settled down. --Johnjbarton.johnjbarton.com 16:56, 20 October 2006 (EDT))
- Go to Platform Plug-in Developer Guide > Programmer’s Guide > Advanced Resources concepts > Project natures
- Eclipse online article “Project Natures and Builders”
- This article shows how to bind a project nature to a builder.
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.