mavenmaven-site-plugin

Multi module POM - creating a site that works


I have a multi module application, and I’m trying to generate a Maven site for this app.

I have an aggregating POM that holds all the child modules, an inheritance POM that holds all the common features for the child modules, and a 20 or so child modules.

I have cycled through endless online examples of how to get this to work. In none of these does the multi module part of this work. I can get the individual site output built OK, in the target/site folder of the children (and the aggregating module). I’ve also had it staging into a target/staging folder in the aggregating POM. The created stuff looks good.

But:

None of the child module links work.

I’ve tried running this under jetty, as some comments on this problem say the links only work when it’s built as a web site – but no, same problem, it can’t find the index.html of the child.

Does anyone have an example of this working? And to avoid me tearing out any more hair (god knows it’s running out up there as it is) I’d rather see the actual working POM code and/or the stages followed to correct test and deploy.

Can anyone help?


Solution

  • OK, finally got this working.

    Add this (only) to the parent POM, changing staging folder as required:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
        <configuration>
         <stagingDirectory>C:\temp\stage</stagingDirectory>
         <reportPlugins>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-project-info-reports-plugin</artifactId>
             <version>2.4</version>
           </plugin>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-javadoc-plugin</artifactId>
             <version>2.8</version>
             <configuration></configuration>
             <reportSets>
               <reportSet>
                 <id>non-aggregate</id>
                 <configuration>
                   <!-- Specific configuration for the aggregate report -->
                   <sourcepath>${project.build.sourceDirectory}/../generated</sourcepath>
                 </configuration>
                 <reports>
                   <report>javadoc</report>
                 </reports>
               </reportSet>
               <reportSet>
                 <id>aggregate</id>
                 <configuration>
                   <!-- Specific configuration for the aggregate report -->
                   <sourcepath>${project.build.sourceDirectory}/../generated</sourcepath>
                 </configuration>
                 <reports>
                   <report>aggregate</report>
                 </reports>
               </reportSet>
             </reportSets>
           </plugin>
            <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-report-plugin</artifactId>
             <version>2.6</version>
           </plugin>
         </reportPlugins>
        </configuration>
    </plugin>
    

    Add this to distribution management section of the parent:

    <site>
      <id>${project.artifactId}-site</id>
      <url>./</url>
    </site>
    

    Then run

    mvn site site:stage
    

    This should deploy into temp/site with working links.