如何获得maven-site-plugin来解析多模块Maven项目的父pom.xml?

如何获得maven-site-plugin来解析多模块Maven项目的父pom.xml?

问题描述:

我有一个花园变种Maven项目.它包含几个模块.因此,根pom.xml以盛大的Maven方式同时充当父级和聚合器.

I have a garden variety Maven project. It has several modules in it. Thus the root pom.xml serves as both parent and aggregator in grand Maven fashion.

该项目可以很好地构建和安装.

This project builds and installs fine.

pom.xml继承自具有以下节的公司pom.xml:

The root pom.xml inherits from a corporate pom.xml with a stanza like this:

<parent>
  <groupId>foo</groupId>
  <artifactId>bar</artifactId>
  <version>16</version> <!-- look, Ma, no SNAPSHOT -->
</parent>

当我对此根pom.xml运行mvn site时,maven-site-plugin 3.2版报告它无法解析父级.

When I run mvn site against this root pom.xml, the maven-site-plugin version 3.2 reports that it cannot resolve the parent.

父母当然在我的本地存储库和我的本地Nexus中.生命周期的其他任何阶段都无法解决父级问题.

The parent is of course present in my local repository and in my local Nexus. No other phase of the lifecycle has any trouble resolving the parent.

其他人具有报告了此问题.关于此主题,还有另一个*问题,但目前尚不清楚它的问题与我的问题完全相同.

Others have reported this issue. There is also another * question on this subject but it was not immediately apparent that its issue was the exact same as mine.

<relativePath/>添加到上面的<parent>节(我的第一个想法)并没有以任何方式改变行为.

Adding <relativePath/> to the <parent> stanza above (my first thought) did not alter the behavior in any way.

如何获取maven-site-plugin来解决父级pom.xml?

这是 bug 在Maven网站插件中.出于各种原因,Maven网站插件只会在它认为是Maven中心的地方寻找依赖项.

This is a bug in the Maven site plugin. The Maven site plugin for various reasons will only ever look for dependencies in what it thinks is Maven central.

因此,您要么必须:

  1. 具有一个<mirror>元素,可以通过您自己的Nexus服务器代理*服务器.
  2. 在本地Maven存储库中,找到父pom工件区域.编辑其_maven.repositories文件,以便将任何提及的存储库名称替换为空字符串.
  1. Have a <mirror> element that proxies central through your own Nexus server.
  2. In your local Maven repository, find the parent pom artifact area. Edit its _maven.repositories file so that any mention of the repository name itself is replaced with an empty string.

我选择了后者.在此之后,构建运行正常.

I chose the latter option. After this the build runs fine.