My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://utku-utkan.appspot.com/
and update your bookmarks.

Pages

Thursday, February 28, 2008

Multiple Module Projects with Eclipse

Maven is a great tool to manage your projects and Eclipse is a great IDE to develop applications. However, there are some points Maven and Eclipse repel with each other. One of them is the project layout. Eclipse insists on flat project layout. On the other hand, Maven manages multiple module projects with hierarchical layout by default. For example, consider a demo project that consists of two sub-modules demo-core and demo-ui. According to Maven defaults, project layout will be as follows:

demo
|-- pom.xml
|-- demo-core
|   `-- pom.xml
`-- demo-ui
    `-- pom.xml


This layout leads to some problems when you want to import these projects (demo, demo-core, and demo-ui) into Eclipse. One way to solve this issue is to configure Maven for using flat project layout. Directory structure for this kind of layout will be as follows:

demo
`-- pom.xml
demo-core
`-- pom.xml
demo-ui
`-- pom.xml


This is what Eclipse really likes. Off course, this does not happen by itself. First, we should modify the modules element of the parent POM as follows:

<modules>
    <module>../demo-core</module>
    <module>../demo-ui</module>
</modules>


After this small change, you can develop your multiple module projects in an Eclipse environment with no problem.

No comments: