Due to the workspace idea many Eclipse users are used to a flat layout and therefore want to keep this structure. The following sample shows how to handle maven multiple module projects with Eclipse for both the standard maven hierachical project layout and the flat Eclipse-like layout.
Suppose Eclipse is your favorite SCM client, this step by step example shows how to set up a new mutiple module project.
mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse
<packaging>pom</packaging>
cd guide-ide-eclipse mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse-site mvn archetype:create -DgroupId=guide.ide.eclipse.core -DartifactId=guide-ide-eclipse-core mvn archetype:create -DgroupId=guide.ide.eclipse.module1 -DartifactId=guide-ide-eclipse-module1
<modules> <module>guide-ide-eclipse-site</module> <module>guide-ide-eclipse-core</module> <module>guide-ide-eclipse-module1</module> </modules>
<parent> <groupId>guide.ide.eclipse</groupId> <artifactId>guide-ide-eclipse</artifactId> <version>1.0-SNAPSHOT</version> </parent>
<dependency> <groupId>guide.ide.eclipse.core</groupId> <artifactId>guide-ide-eclipse-core</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
mvn install mvn eclipse:eclipse
target .classpath .project .wtpmodules
Even the parent project should have this .cvsignore-file. Eclipse will automatically generate a new simple .project-file when you check out the project from the repository.
From now on you have different options to proceed. If you are working on all modules simultanously and you'd rather have Eclipse project dependencies than binary dependencies, you should set up a new workspace and import all projects from step-by-step/guide-ide-eclipse. Note, you have to delete the .project-file of your parent project before. The result is the same as checking out the whole project from the command line, running mvn eclipse:eclipse and finally importing the projects into your Eclipse workspace. In both cases you will be able to synchronize your changes using Eclipse.
In case of large projects with many developers involved, it can be tedious to check out all modules and keep them up to date. Especially if you are only interested in one or two modules. In this case using binary dependencies is much more comfortable. Just check out the modules you want to work on with Eclipse and run mvn eclipse:eclipse for each module (see also Maven as an external tool. Of course, all referenced artifacts must be available from your maven repository.
It is possible to move the parent POM in its own directory on the same level with the referenced modules, thus resulting to a Flat Project Layout.
Using a Flat Project Layout you can checkout and edit the parent POM without checking out the whole project.
<modules> <module>../guide-ide-eclipse-site</module> <module>../guide-ide-eclipse-core</module> <module>../guide-ide-eclipse-module1</module> </modules>
Issue: The Maven Release Plugin does not support the flat structure (MRELEASE-261).