Skip to content

Support for implicit project natures #1133

@laeubi

Description

@laeubi

Currently one has to configure natures on a project explicitly so they are persisted in the .project file.

This is very unflexible and has some drawbacks:

  1. Natures can be missing and one gets a warning then
  2. A required nature for a project might disable functions and the user has to find out why the desired function is not there
  3. We need to have code to explicitly enable natures or "convert" projects
  4. It requires to retain project files in the SCM

Instead I think we should have some way to implicitly enable a nature on a project (without persisting it) based on the enable we already have for run shortcuts for example:

<enablement>
               <with variable="selection">
                  <count value="1"/>
               	  <iterate>
                      <adapt type="org.eclipse.jdt.core.IJavaElement">
		                <test property="org.eclipse.jdt.core.isInJavaProjectWithNature" value="org.eclipse.pde.PluginNature"/>
		                <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="junit.framework.Test"/>
		                <test property="org.eclipse.jdt.junit.canLaunchAsJUnit" forcePluginActivation="true"/>
		             </adapt>
		          </iterate>
               </with>
 </enablement>

for example in pde one has the pluginNature that might be enabled when there is a META-INF/MANIFEST.MF file, in fact tycho-pomless is working that way with great success, also m2e nature can be enabled by having a pom.xml, a java nature is probabbly always useful if any *.java file is in the project and so on, for the case that one does NOT want a nature we then can have a syntax like <nature>!org.eclipse.pde.PluginNature</nature> to explicitly disable a nature if desired.

Please note that this will not automatically enable any builders or classpath entries, these will still need to be explicitly set so this will only enable e.g. menu entries or other actions / code to build on the fact that a given nature was detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions