Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install parent POM without building Child modules

People also ask

Is parent tag mandatory in POM xml?

Yes, maven reads the parent POM from your local repository (or proxies like nexus) and creates an 'effective POM' by merging the information from parent and module POM. One reason to use a parent is that you have a central place to store information about versions of artifacts, compiler-settings etc.

Can a Maven POM have 2 parents?

Maven does not support multiple inheritance and a project can have only one parent. The parent project can have its own hierarchy.

What is the use of parent POM and child pom xml file?

A parent pom. xml file (or super POM) in Maven is used to structure the project in order to avoid redundancies and duplicate configurations by using an inheritance between different pom. xml files. If any dependency or properties are configured in both - parent and child - pom.


Use the '-N' option in the mvn command.

From mvn -h:

-N,--non-recursive Do not recurse into sub-projects


While Guillaume is indeed right and that is the correct option, I would personally recommend keeping your parent as a separate module.

I find the best approach for inheritance to be as follows:

aggregator
|- module1/ (extends parent)
| |- pom.xml
|- module2/ (extends parent)
| |- pom.xml
|- parent/
| |- pom.xml
|- pom.xml

This way you can always install the parent only, with mvn clean install without extra options.

You can also have the parent outside the aggregator so you can re-use it between more projects.

There are numerous benefits to keeping the parent and the aggregator as two separate things. But in the end, you choose what's best for your project/environment.