> On 3 May 2025, at 18:23, se...@posteo.de wrote:
> 
> Hello!
> 
> I have trouble getting the Maven Site Plugin to work in a multi-module when 
> the aggregating project is not the same as as the parent project.
> 
> My small example project (uploaded here [1]) consists of three modules: 
> aggregator, parent and child. aggregator aggregates the two other projects, 
> parent is the parent project of child.
> 
> In a project where the aggregator is also the parent project I just had to 
> define <url> inside <distributionManagement> in this aggregator-parent 
> project and it worked. In this case, however, it doesn't work, unfortunately. 
> In [2] the following is stated:
> 
> "The pom.xml of the topmost project in a multi-module build must define the 
> distributionManagement URL element (called "rootURL" hereafter). The rootURL 
> must be the topmost distributionManagement URL in the multi-module project, 
> implying that any distributionManagement URL defined within another project 
> in a multimodule build must start with the rootURL and append unique paths 
> (to be situated "below" the rootURL)."
> 
> I tried to implement this by using
> - <url>https://test.com/aggregator/</url> for the aggregator project
> - <url>https://test.com/aggregator/parent/</url> for the parent project
> - <url>https://test.com/aggregator/child/</url> for the child project
> 
> I also tried using different variations in which the the parent project is 
> treated as the topmost project <url>-wise.
> 
> As can be seen from the output of "mvn clean site site:stage 
> -DstagingDirectory=C:\temp\foo" in the linked GitHub project the paths to 
> which the sites are pushed are not correct (partially overwriting each other).
> 
> Could give me some hints how to set this up correctly?

Due to how your project is setup (the aggregator not being the parent to your 
parent module) site:stage considers your parent project site as the topSiteURL 
(top-level parent) for parent and child project, so parent’s site is assumed to 
be the root site and child’s site is relativized from the parent’s site.

> 1271 [main] [DEBUG] org.apache.maven.plugins.site.deploy.SiteStageMojo - 
> staging top distributionManagement.site.url found in 
> com.github.seekM.maven-site-test-aggregator-parent-separate:parent:pom:1.0-SNAPSHOT
>  with value: https://test.com/aggregator/parent/
> 1271 [main] [DEBUG] org.apache.maven.plugins.site.deploy.SiteStageMojo - 
> Mapping url source calculation: 
> 1272 [main] [DEBUG] org.apache.maven.doxia.tools.DefaultSiteTool - Mapped 
> url: https://test.com/aggregator/child/ to relative path: ../child
> 1272 [main] [DEBUG] org.apache.maven.plugins.site.deploy.SiteStageMojo - 
> distributionManagement.site.url relative path: ../child
> 1272 [main] [DEBUG] org.apache.maven.doxia.tools.DefaultSiteTool - Mapped 
> url: https://test.com/aggregator/child/ to relative path: ../child

To fix this up and keep all your projects in a single site with parent and 
child as subfolders you can configure the topSiteURL [3] in the parent module 
plugin management section to the site URL of the aggregator:

diff --git a/parent/pom.xml b/parent/pom.xml
index 2a3acdf..e8bfb71 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -22,6 +22,9 @@
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-site-plugin</artifactId>
                     <version>3.21.0</version>
+                    <configuration>
+                        <topSiteURL>https://test.com/aggregator/</topSiteURL>
+                    </configuration>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>

[3] 
https://maven.apache.org/plugins/maven-site-plugin/stage-mojo.html#topSiteURL

> 
> [1] https://github.com/seekM/maven-site-test-aggregator-parent-separate
> [2] 
> https://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html
> 
> Thanks a lot and best regards
> Tobias
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

Reply via email to