Skip to Content
Scope: All Project Types

Description

The hasNature condition is an Ant condition that can be used to check if a project has a specific nature. Natures are used to assign specific behaviour to Eclipse projects. Java projects for example have the nature 'org.eclipse.jdt.core.javanature'.

The hasNature condition can be used with ant's native condition and waitfor tasks (see Condition Task). It can also be used with the if-task from the ant-contrib project to create build steps that check whether a project has some specific nature.

Arguments

The hasNature datatype provides the following arguments:

Argument Description Required
workspaceDirectory Absolute path of the workspace directory Either 'workspaceDirectory' or 'workspaceId' has to be specified
workspaceId The identifier of a defined workspace (see <workspaceDefinition>) Either 'workspaceDirectory' or 'workspaceId' has to be specified
projectName Name of the eclipse project yes
nature Name of a Nature that should be checked yes

Example usage

The following example checks if the project with the name 'simple.java.project' has the nature 'org.eclipse.jdt.core.javanature':

<antcontrib:if>
    <ant4eclipse:hasNature workspacedirectory="${workspace}"
                           projectname="simple.java.project"
                           nature="org.eclipse.jdt.core.javanature" />
   <antcontrib:then>
     ...
   </antcontrib:then>
 </antcontrib:if>