[英]Maven: How to deal with modules that contain modules?
以前,我使用过由两个层次结构组成的多模块 Maven 项目。 父 POM 后跟它们自己目录和 POM 中的模块。
但是现在我接管了一个包含父级的项目,然后是再次包含模块的模块。
这一切都是根据 Maven 指南还是我正在处理定制的东西?
以及如何解释这些子模块? 知道可以给我指点的指南吗?
我可以成功运行所有 Maven 生命周期。 虽然我不确定是否以及如何重构应用程序并开始插入我自己的代码。
这是我的项目结构树,只剩下几个模块:
top-parent
| pom.xml (modules: applications, checks, core, test)
|
+---applications
| | pom.xml (parent: top-parent) (modules: batch, surefire, web)
| <parent>
| <artifactId>applications</artifactId>
| <groupId>com.a.b.codechecker</groupId>
| <version>1.0</version>
| </parent>
| <artifactId>batch</artifactId>
|
| |
| \---web
| | pom.xml
| <parent>
| <groupId>com.a.b.codechecker</groupId>
| <artifactId>applications</artifactId>
| <version>1.0</version>
| </parent>
| <artifactId>web</artifactId>
|
+---checks
| | pom.xml (parent: top parent) (modules: aggregator, blacklist-check)
| <parent>
| <groupId>com.a.b.codechecker</groupId>
| <artifactId>parent</artifactId>
| <version>1.0</version>
| </parent>
| <groupId>com.a.b.codechecker.checks</groupId>
| <artifactId>checks</artifactId>
| |
| +---aggregator
| | pom.xml
<parent>
<artifactId>checks</artifactId>
<groupId>com.a.b.codechecker.checks</groupId>
<version>1.0</version>
</parent>
<artifactId>aggregator</artifactId>
我提供以下几个大纲。
根据问题,这一切都是根据 Maven 指南还是我正在处理定制的东西?
是的,你可以有Parent,Child,Grand child类型的模块结构。Parent和Child类型的maven多模块层次结构很简单,但在某些情况下,开发人员设计在一个模块中有几个子模块。 如果您有一个包含 n 个模块和 m 个子模块的大型项目,对于不同级别的开发人员来说,它会变得很复杂。
根据这个问题,以及如何解释这些子模块? 知道可以给我指点的指南吗? 如何进行简单管理取决于开发团队。 我建议,如果您有许多子模块,您可以创建/维护另一个独立项目,并且可以在需要的地方将依赖项添加到主项目中。 它将为您提供该项目的粒度和单独的团队工作,而无需考虑主项目。
对于大型项目,始终建议维护独立项目,您可以在其他项目中添加依赖项。 为此,您可以使用 Nexus 或 Artifactory 进行工件管理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.