当根 pom 具有两个或多个 child 模块通用的插件时的 Maven 循环引用

Maven Cyclic reference when root pom has plugin which is common to two or more child modules

所以我有一个结构如下的项目-:

pom.xml
\
 ---Module A (Child)
 ---Module B (Maven child  plugin with Dependency on A)
 ---Module C (Child Dependency on A)
 ---Plugin B

parent pom 如下所示

<modules>
<module>A</module>
<module>B</module>
<module>C</module>
</modules>

<plugins>
<plugin>
  B
</plugin>
</plugins>

A 的 POM 没有依赖项,只有 parent-: parent

B 的 POM 有

<parent>parent</parent>
<dependencies>
      <dependency>A</dependency>
</dependencies>

C 的 POM 也有

<parent>parent</parent>
<dependencies>
      <dependency>A</dependency>
</dependencies>

有了上面的内容,maven 给了我以下错误-:

org.apache.maven.ProjectCycleException:反应器中的项目包含循环引用:

'B'和'A'之间的边在图中引入循环A->parent->B->A

我哪里做错了,我应该如何构建项目?我想把所有东西都放在一个地方。

你应该将你的插件声明在父级中移动到 pluginManagement 标签中,这样你就可以设置版本(但不是实际使用它),然后在需要插件的个别项目中,简单地命名plugins 标签中的插件。

另外,如果 B 依赖于 AA 不能使用插件 B。对不起,做不到;你需要找到一种方法,让一个人在没有另一个人的情况下做事。此外,我认为 B 不能将其自身用作插件,因为在它甚至可以开始构建 B 之前必须解决这个问题。 C 和任何其他模块(DE 等)可以使用 B