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

时间:2015-03-31 20:28:02

标签: java maven svn maven-site-plugin

我在使用Maven网站插件时遇到了一些麻烦。我有以下样本结构:

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

我们有一个模块带有标签/ 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>

嵌套在trunk目录中的模块由于某种原因使相对URL(module-1 / module-1)加倍,而另一个(/ module-2)变为正常。我在某些Maven惯例中失败了还是遗漏了其他东西?

编辑:这是有效的pom,真正的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>

1 个答案:

答案 0 :(得分:0)

From the documentation of Maven Site Plugin:

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

In fact it's only half of the story: as soon as the parent project is not the direct ancestor, Maven will generated inadequate url and site/url values. E.g. with a parent project which is not the root project.

Or here with module-1/trunk. In such a case you have to declare explicitely the url and site/url.