| 17 May 2008 |
Because I have been using Maven for some years now, I decided it was time to post a way to consistently setup a Maven project with nested module in Eclipse. At most projects until now I just played around with Eclipse to get the setup correctly.
This is how I do it now:
-
In Eclipse 3.2.2 I install the Maven2 plugin from this location.
-
I open up a command prompt and create a new module with: (I assume you have already succesfully installed Maven)
mvn archetype:create -DgroupId=net.pascalalma.myproject -DartifactId=myproject-core
This gives the following output (if the plugin is downloaded and installed before):
-
Then I create a Eclipse project for this module like this:
mvn eclipse:m2eclipse
This gives the following output (if plugin is downloaded and installed before):
-
Next step is to import the project in Eclipse:

One final thing about Maven2 and Eclipse files:
When using a source version system (like SubVersion, for example) it is good practice to exclude the generated code and files from the versioning system. That’s why the following files shouldn’t be checked in SVN:
- target dir
- .project file
- .classpath file
- .settings dir
When using SVN and TortoiseSVN (my favourite SVN client) you can add the directory to the ‘ignore list’ by right clicking the folder and choose the option to add it to the ignore list, like this:


