Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

Top 5 Exciting Maven Multi-Module Project Ideas & Topics for Beginners

By Rohan Vats

Updated on Nov 23, 2022 | 8 min read

Share:

As any project gets more complex and layered, the correct way to manage it is by splitting it into different modules. In Maven, while it is possible to link these multiple projects as dependencies, it makes the build process a lot more complex. Therefore, the preferred approach is to structure the project as a multi-modular one and pass on the rest to Maven. 

Check out our free courses to get an edge over the competition.

Benefits of Using Multi-Modules in Maven

The significant advantage of using multi-modules instead of dependency injection or any other procedure is that it reduces duplication. To understand this better, suppose you’re working on an application that consists of two modules – let’s say the backend module and the frontend module. 

If you work on both of those modules and change certain functionalities that affect both the modules, you’ll need to build both the modules or components isolatedly without a specialised build tool. Or, you must write a script to compile the code, run tests, and display the final results.

Now, if the complexity increases even further and your project has more than two modules, it’ll become progressively harder to perform this task without a specialised build tool. Further, in real-world problems, your projects may require some Maven plugins to perform some crucial operations during the entire build lifecycle, share dependencies, or include other BOM projects. 

As a result of these challenges, the multi-modules in Maven are extremely helpful and let you build the application’s modules in a single command line. It also allows you to share a vast amount of data and configuration between multiple modules seamlessly. 

Check out upGrad’s Advanced Certification in Cyber Security

Also Read: Maven Interview Question Answer 

Key Terms to Know Regarding Multi-Module Projects in Maven

1. Parent POM (Project Object Module)

Each pom.xml file in Maven – for the support of inheritance – has a parent POM, known as the Super POM. This can be located in the Maven binaries, and you can also merge the two files to create the Effective POM. 

So, you can create your own pom.xml file to serve as the parent for your project. Once you’ve done that, you can add all the dependencies and configuration, set it as the parent of the child modules, and enable inheritance. Except for inheritance, Maven also provides aggregation. The Parent POM that leverages the aggregation functionality is known as the aggregate POM – this kind of POM declares the child modules explicitly in the pom.xml file. 

Check out upGrad’s Advanced Certification in Blockchain 

2. Submodules

Subprojects, also known as submodules, can be understood as standard Maven modules that inherit from the parent POM. Using inheritance, the modules share various dependencies and configurations. However, if you need to build the project quickly, you’ll need to explicitly declare the submodules in the Parent POM, making it the aggregate POM. 

3. The Simple Multi-Module Project

App and util are two modules that are contained in The Simple Multi-Module Project. The util module is required for providing a static method to join or append different strings using Apache Commons Lang library, and the app module is necessary to call the util module. Here’s a snippet from the app.java file: 

simple-multi/app/src/main/java/app/App.java
public class App {
    public static void main(String[] args) {
        System.out.println(new App().greet(“World!”));
    }
    public String greet(String name) {
        return Util.join(“Hello “, name);
    }
}
To build the project, run
$ cd simple-multi
$ mvn clean test

Maven’s code builder builds both the modules of your project in the correct order, performs the necessary tests, and outputs the results in an easily understandable summary format, like below: 

4. Structure of a Multi-Module Project

Here’s the layout of a simple Multi-Module project:

The simple-multi directory is the root directory and is present at the very top of the entire project. It contains the top-level POM (Parent POM), but this Parent POM doesn’t have any source folder. 

The top-level directory also contains app and util, which are regular Maven projects with directories and pom.xml file. 

The top-level POM and the module POM differ slightly from the regular POM. Let’s look in detail as to what they contain: 

5. Top Level POM

A Parent POM or a top-level POM is required by the Maven Multi-Module Project at the root directory. 

The top-level POM defines important aspects and project coordinates like artifactID, version, and groupID, as in any normal project. However, the packaging type for this is not in the usual war or jar format but as a pom. This is because the top-level module doesn’t contain any further source directory. The modules/module elements add the app and util modules. 

The content of this file include: 

simple-multi/pom.xml

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.codetab</groupId>

  <artifactId>simple-multi</artifactId>

  <version>1.0</version>

  <packaging>pom</packaging>

  <modules>

      <module>app</module>

      <module>util</module>

  </modules>

</project>

To sum it up, the top-level POM specifies the pom packaging type and explicitly lists all the submodules. 

Keep in mind that you don’t need to worry about the ordering while declaring submodules in the Parent POM as Maven uses a Reactor to order the listed modules correctly. In the simple-multi, maven builds util module and then app since the app depends on util.

5. Module POM

The Module POM folder contains a regular source folder and its own pom.xml file. The content of this util/pom.xml are: 

util/pom.xml

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

   xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

   <modelVersion>4.0.0</modelVersion>

   <parent>

       <groupId>org.codetab</groupId>

       <artifactId>simple-multi</artifactId>

       <version>1.0</version>

   </parent>

   <artifactId>util</artifactId>

   <properties>

       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

       <maven.compiler.source>1.8</maven.compiler.source>

       <maven.compiler.target>1.8</maven.compiler.target>

   </properties>

   <dependencies>

       <dependency>

           <groupId>org.apache.commons</groupId>

           <artifactId>commons-lang3</artifactId>

           <version>3.6</version>

       </dependency>

       <dependency>

           <groupId>junit</groupId>

           <artifactId>junit</artifactId>

           <version>4.12</version>

           <scope>test</scope>

       </dependency>

   </dependencies>

</project>

There is no need to specify the groupID and version for the module as they’ll be inherited from the parent. The dependencies/dependency block defines the dependencies of util module – commons-lang3 and JUnit.

Now, let’s look at the app/pom.xml, which is quite similar to the util/pom.xml, except for the dependencies block, which is shown below:

app/pom.xml

….

<dependencies>

    <dependency>

        <groupId>org.codetab</groupId>

        <artifactId>util</artifactId>

        <version>1.0</version>

    </dependency>

    ….

</dependencies>

The app module uses methods from the util module, and for this, the app/pom.xml specifies util as the dependency.

To summarise all the things explained above:

The top-level project (parent project),

  • Defines top-level pom.xml, which specifies all the coordinates and submodules, and sets the packaging type as pom. 
  • Contains the further modules folders. 
  • Contains no source folders. 

Each of the module folders is nothing but regular Maven project directories. However, the pom.xml file contains:

  • The parent element specifies the module’s parent.
  • Module coordinates are specified in the artifactID element. GroupID and version are not mentioned as they are inherited from parent coordinates. 
  • The dependency, if one module depends on another, is mentioned in the dependencies/dependency element.

Executing the Multi-Module Project

$ mvn clean package command can be used to compile, test, and package the multi-module. However, to run it with the maven-exec-plugin requires the following steps: 

Run the following commands: 

$ cd simple-multi

$ mvn clean install

$ mvn exec:java -pl app -Dexec.mainClass=app.App

The install command installs the modules to your local repository, where you can then run the project. The option -pl app informs the exec plugin about the app module and runs its class app.App. Without install, the build process fails, as Maven cannot download and resolve the util module dependency.

However, it is quite cumbersome to install the project in a local repository each time before each run, especially when in the development phase. To ease that, you can directly execute the multi-module in Eclipse IDE without performing the install step. 

Learn Software development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

Conclusion

We hope this article helped you in getting started with the Maven Multi-Module process. As is with anything new, it’s just about getting the initial hang of it. Once you’ve understood the basic structure and functioning, you’ll be on your way to seamlessly manage multiple modules in Maven. 

If you’re interested to learn more about full-stack software development, check out upGrad & IIIT-B’s Executive PG Programme in Software Development – Specialisation in Full Stack Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects, and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.

Frequently Asked Questions (FAQs)

1. What are multi-modules projects?

2. What is a project object model file in maven?

3. How to create a maven multi-module project?

Rohan Vats

419 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

India’s #1 Tech University

Executive PG Certification in AI-Powered Full Stack Development

77%

seats filled

View Program

Top Resources

Recommended Programs

Suggested Blogs