Maven 多模块环境中 distributionManagement 站点 URL 的问题

Problems with distributionManagement site URL in Maven multi module environment

我在使用 Maven 站点插件时遇到了一些问题。我有以下示例结构:

/parent-project
    pom.xml
    /src/site
    /module-1
         /branches
         /tags
         /trunk
             pom.xml
             /src
    /module-2
         pom.xml
         /src

我们有一个模块具有 tag/branches/trunk 结构,另一个没有(第一个模块有自己的部署周期)。 假设父 pom.xml 是这样的:

<groupId>some.group</groupId>
<artifactId>parent-project</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<url>https://url/parent</url>

<modules>
     <module>module-1/trunk</module>
     <module>module-2</module>
<modules>

<distributionManagement>
    <site>
        <id>deployment</id>
        <url>dav:https://url/deploy/site/</url>
    </site>
</distributionManagement>

当我查看模块的有效 pom 时,我们得到如下内容:

<parent>
   <groupId>some.group</groupId>
   <artifactId>parent-project</artifactId>
   <version>1.0</version>
</parent>

<groupId>some.group</groupId>
<artifactId>module-1</artifactId>
<version>2.0.0</version>

<url>http://url/parent/module-1/module-1</url>

<distributionManagement>
    <site>
        <id>deployment</id>
        <url>dav:https://url/deploy/site/module-1/module-1</url>
    </site>
</distributionManagement>

<parent>
   <groupId>some.group</groupId>
   <artifactId>parent-project</artifactId>
   <version>1.0</version>
</parent>

<groupId>some.group</groupId>
<artifactId>module-2</artifactId>
<version>2.0.0</version>

<url>http://url/parent/module-2</url>

<distributionManagement>
    <site>
        <id>deployment</id>
        <url>dav:https://url/deploy/site/module-2</url>
    </site>
</distributionManagement>

嵌套在主干目录中的模块由于某种原因增加了一倍的相对 url (module-1/module-1),而另一个 (/module-2) 正常。我是在一些 Maven 约定上失败了还是遗漏了什么?

编辑: 这是有效的 pom,真实的只是最小的:

<groupId>some.group</groupId>
<artifactId>parent-project</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<url>https://url/parent</url>

<modules>
     <module>module-1/trunk</module>
     <module>module-2</module>
<modules>

<distributionManagement>
    <site>
        <id>deployment</id>
        <url>dav:https://url/deploy/site/</url>
    </site>
</distributionManagement>

<parent>
   <groupId>some.group</groupId>
   <artifactId>parent-project</artifactId>
   <version>1.0</version>
</parent>

<groupId>some.group</groupId>
<artifactId>module-1</artifactId>
<version>2.0.0</version>

<parent>
   <groupId>some.group</groupId>
   <artifactId>parent-project</artifactId>
   <version>1.0</version>
</parent>

<groupId>some.group</groupId>
<artifactId>module-2</artifactId>
<version>2.0.0</version>

来自 Maven 站点插件的 documentation

If subprojects inherit the site URL from a parent POM, they will automatically append their to form their effective deployment location.

事实上这只是故事的一半:只要父项目不是直接祖先,Maven 就会生成不适当的 url 和 site/url 值。 例如。使用不是根项目的父项目。

或此处 module-1/trunk。在这种情况下,您必须明确声明 url 和 site/url.