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

EclipseMavenM2eclipse

Eclipse Problem Overview


I'm a beginner at Maven and I've played with it from a command line point of view a little, so now I was trying to use it in Eclipse; I installed the m2eclipse plugin to do so.

But I'm stumped from the very beginning! Apparently I've missed a bit of terminology somewhere along the line. I can't keep track of all these new Maven terms... What is a Maven Project, and what is a Maven Module? These are my options when creating a new project in the Maven category in Eclipse.

Eclipse Solutions


Solution 1 - Eclipse

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)

Solution 2 - Eclipse

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRicketView Question on Stackoverflow
Solution 1 - EclipseSteveView Answer on Stackoverflow
Solution 2 - EclipseRicketView Answer on Stackoverflow