01 November 2014

How easy it is to create a multi module maven project

It is very easy.. no complexity presented here ..

The multi module project is folder with a parent pom file and some sub modules, each is a maven project reside in the directly of the parent project (also can reside in any relative path, not necessary to be in the parent folder).

And the parent project itself is a regular maven project but without src folder and with packaging `pom` instead of  `jar` or `war`...

If you have a shared dependency, as if you work with spring framework, you can put the shared dependencies in the parent pom. and in sub modules pom you can put unique dependencies and also can have one module depend on others (web app module to depend on domain module and repository module)

The following is directory structure using parent module with two sub modules (quick-start and webapp)

pom.xml
my-model-app
|____.classpath
|____.project
|____.settings
| |____org.eclipse.jdt.core.prefs
| |____org.eclipse.m2e.core.prefs
| |____org.eclipse.wst.common.component
| |____org.eclipse.wst.common.project.facet.core.xml
|____pom.xml
|____src
| |____main
| | |____java
| | | |____com
| | | | |____me
| | | | | |____model
| | | | | | |____App.java
| |____test
| | |____java
| | | |____com
| | | | |____me
| | | | | |____AppTest.java
my-web-app
|____.classpath
|____.DS_Store
|____.project
|____.settings
| |____.jsdtscope
| |____org.eclipse.jdt.core.prefs
| |____org.eclipse.m2e.core.prefs
| |____org.eclipse.wst.common.component
| |____org.eclipse.wst.common.project.facet.core.xml
| |____org.eclipse.wst.jsdt.ui.superType.container
| |____org.eclipse.wst.jsdt.ui.superType.name
| |____org.eclipse.wst.validation.prefs
|____pom.xml
|____src
| |____.DS_Store
| |____main
| | |____java
| | |____resources
| | |____webapp
| | | |____index.jsp
| | | |____WEB-INF
| | | | |____web.xml


Note, the .classpath and other eclipse files are added because I've imported the project in eclipse.

Now it is very easy, go ahead and create your multi module maven project.

Post a Comment