Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven "Module" vs "Project" (Eclipse, m2eclipse plugin)

People also ask

What is the difference between Maven project and Maven module?

a maven module is like a maven "sub-project". a maven project includes 1 or more modules. more info here. Typically, a module generates a single artifact (jar, war, zip, etc), although this is not always true.

What is Maven module?

A Maven module is a sub-project. To create a Maven module you will need to already have a Maven project available. The parent project must have its Packaging option pre-configured to pom, for a module to be created and associated with it.

What are the advantages of multi module Maven project?

Multi modules can help you with re-use your code. It's one of the best benefits you'll feel in work. Imagine if you have 3 web projects with a security layer, You'll have to copy paste your code 3 times and trying connect it with each project. But what if you create a security module a project with a specific job.


They are basically the same thing, but with one difference.
When you create a module, you must specify a parent project.
When you specify the parent project, it adds a <modules> section to the parent projects pom.xml.
That section basically says to the parent project:
run every command I get against all of my modules first
So for example, if you run, mvn package on the top-level project, it will run mvn package against all its module projects first.

Hope that helps.

Hint:
Make sure all modules have high cohesion and related to each other, otherwise you will have a huge messy project without applying SRP (Single Responsibility Principle)


Found it! My searches were returning tons of hits for creating a "multi-module project", but once I added "-multi" to my query, the answer was on the first page.

According to Creating and Importing Projects:

m2eclipse provides the ability to create a Maven module. Creating a Maven module is almost identical to creating a Maven project as it also creates a new Maven project using a Maven archetype. However, a Maven module is a subproject of another Maven project typically known as a parent project.