Install parent POM without building Child modules

JavaMavenMaven 2pom.xml

Java Problem Overview


I have a parent POM in a Maven project, with this structure:

             parent
               |
        ---------------
        |             |
      child1       child2

I want to install the POM of the "parent" in the local REPO to allow child1 take some changes that I did in the dependencyManagement, but I cannot do a regular "clean install" because "child2" is broken and will not build.

Which is the proper way to do this with maven (other than going to the parent pom and commenting the "child2" module).

Java Solutions


Solution 1 - Java

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

From mvn -h:

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

Solution 2 - Java

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.

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
QuestionMr.EddartView Question on Stackoverflow
Solution 1 - JavaGuillaume PoletView Answer on Stackoverflow
Solution 2 - JavacarlspringView Answer on Stackoverflow