Search code examples
javamavensvnmaven-site-plugin

Problems with distributionManagement site URL in Maven multi module environment


I'm having some trouble with Maven site plugin. I have the following sample structure:

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

We have one module with the tag/branches/trunk structure and another one without (the first has it's own deploy cycle). Let's say that the parent pom.xml is something like this:

<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>

When I look into the effective pom of the modules we have something like the following:

<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>

and

<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>

The module nested in trunk directory has doubled relative urls (module-1/module-1) for some reason and the other one (/module-2) went normal. Am I failing at some of Maven conventions or missing something else?

EDIT: This is the effective pom, the real ones are just the minimal:

<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>

and

<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>

and

<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>

Solution

  • 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.