Multiple Module Maven Project

Multiple Module Maven Project

Working with Maven single project is easy, If you are working on large project where maven been used probably you might have seen multiple modules are involved and dependent on each other. It’s good idea to separate out the project based on their behaviors/requirement in separate module so that maintenance will be easy and developer can work independently on each module. Here I will show you how to create multiple module maven project and how to handle them.

Tools needed: Eclipse

To start with this let’s create maven parent project first:

  • Create maven parent project –> Open your eclipse –> File –> New –> Other –> Maven –> Maven Project –> Click Next

Multiple Module Maven Project

  • Then follow below screen instruction:

Multiple Module Maven Project

Multiple Module Maven Project

  • You will see parent project got created as below:

Multiple Module Maven Project

  • Now we can add as many as module to this parent. For this demo I will add two child project to type jar packaging and finally will run it through console.
  • Create maven module JavaHonkChild1 –> Right Click JavaHonkParent –> Maven –> Maven Module –> Click Next

Multiple Module Maven Project

Multiple Module Maven Project

Multiple Module Maven Project

  • Now to create maven JavaHonkChild2 module please follow the same instruction as we did for JavaHonkChild1. You will see project structure as below:

Multiple Module Maven Project

  • That’s it. Now to take build just go to parent pom.xml location and use any maven command and for demo I will use below:

Multiple Module Maven Project

  • Once you run this command you will build completed successful message on the console including all child module dependency add in parent project as below:

Multiple Module Maven Project

Multiple Module Maven Project

  • For more information please visit maven official documentation of multiple maven project here

download Download Project:  JavaHonkParent

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *