简体   繁体   English

安装父POM而不构建子模块

[英]Install parent POM without building Child modules

I have a parent POM in a Maven project, with this structure: 我在Maven项目中有一个父POM,具有以下结构:

             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. 我想在本地REPO中安装“父”的POM以允许child1进行我在dependencyManagement中所做的一些更改,但是我不能进行常规的“干净安装”,因为“child2”已经损坏而且不会构建。

Which is the proper way to do this with maven (other than going to the parent pom and commenting the "child2" module). 使用maven执行此操作的正确方法是什么(除了转到父pom并注释“child2”模块)。

Use the '-N' option in the mvn command. 使用mvn命令中的“-N”选项。

From mvn -h : 来自mvn -h

-N,--non-recursive Do not recurse into sub-projects -N, - 非递归不要递归到子项目中

While Guillaume is indeed right and that is the correct option, I would personally recommend keeping your parent as a separate module. 虽然Guillaume确实是正确的,这是正确的选择,但我个人建议将您的父母作为一个单独的模块。

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. 这样,您始终可以使用mvn clean install而无需额外选项来安装父级。

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. 但最后,您选择最适合您的项目/环境的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM