Adding project nature to your Maven pom.xml

Posted on Saturday, December 22, 2007

0


Let us assume that you have a maven based project. This would mean you have a pom.xml if you are using maven 2.

Now if you execute mvn eclipse:eclipse the maven eclipse plugin generated the required .classpath and .project files so that your project can become a first class eclipse project.

However, by default the project nature added is that for a java project and hence the .project file is generated like this, with the java builder and the java nature.

 

<projectDescription>

<name>my-project</name>

<buildSpec>

<buildCommand>

<name>org.eclipse.jdt.core.javabuilder</name>

</buildCommand>

</buildSpec>

<natures>

<nature>org.eclipse.jdt.core.javanature</nature>

</natures>

</projectDescription>

 

 

But what if we want to add aspectj nature to the project and obviously we would want to add them in the pom so that whenever we do mvn eclipse:eclipse we get the aspectj nature of the eclipse project.

The way to do it is like this

 

<build>

<plugins>

<plugin>

<artifactId>maven-eclipse-plugin</artifactId>

<configuration>

<additionalProjectnatures>

<projectnature>

org.eclipse.ajdt.ui.ajnature

</projectnature>

</additionalProjectnatures>

<buildcommands>

<buildcommand>

org.eclipse.ajdt.core.ajbuilder

</buildcommand>

</buildcommands>

</configuration>

</plugin>

 

 

and now if you do mvn eclipse:eclipse then you get the .project file like this

 

<projectDescription>

<name>my-project</name>

<buildSpec>

<buildCommand>

<name>org.eclipse.ajdt.core.ajbuilder</name>

</buildCommand>

</buildSpec>

<natures>

<nature>org.eclipse.jdt.core.javanature</nature>

<nature>org.eclipse.ajdt.ui.ajnature</nature>

</natures>

</projectDescription>


AddThis Social Bookmark Button

Advertisements
Posted in: Maven