Wednesday, February 15, 2012

Maven eclipse plugin configuration "mvn eclipse:eclipse"


let me introduce maven eclipse plugin
there are all the eclipse plugin elements list below
http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html

Basically, I have configured most of needs for my self and our team.
When I make a maven project from eclipse and right mouse click.
I can see maven menu, there are add dependency, update dependency menu and so on.
but, when I made with the command mvn eclipse:eclipse the menu was not showed up.

I found that I need to add project nature on pom.xml

<additionalProjectnatures>
      <projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
     </additionalProjectnatures>


Completed one.
you can omit which you don't need.

<build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.8</version>
    <configuration>
     <additionalProjectFacets>
      <jst.web>3.0</jst.web>
     </additionalProjectFacets>
     <additionalProjectnatures>
      <projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
     </additionalProjectnatures>
     <downloadJavadocs>true</downloadJavadocs>
     <downloadSources>true</downloadSources>
     <wtpdefaultserver>${eclipse.wtpdefaultserver}</wtpdefaultserver>
     <wtpversion>2.0</wtpversion>
    </configuration>
   </plugin>

I can see right .project file after run "mvn eclipse:eclipse" command

Before

<natures>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
  </natures>

After :

<natures>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
    <nature>org.eclipse.m2e.core.maven2Nature</nature>
  </natures>


now I can see "maven2Nature" is added.

Now on I will commit only source files and pom.xml to SVN.
then all of my team member will have same eclipse setting whether they use windows, linux or mac and all of them can see source files and java doc from eclipse. you can add same encoding setting and java jdk version so on.


No comments:

Post a Comment