Use maven-project-info-reports-plugin and maven-site-plugin together: One overwrites the index.html of the other

458 Views Asked by At

In a project I use the maven-project-info-reports-plugin to create the respective project information as well as some reports. I configured the maven-site-plugin to be executed during the install phase, so that the reports are generated for each build. Works fine. So far, so good.

project-info-reports

Now I want to add some custom documentation via the maven-site-plugin, as done for example in maven plugins like (https://maven.apache.org/plugins/maven-site-plugin/index.html). On the bar/menu on the left of that page the stuff under Overview, Examples and so on is created from doxia created pages which are referred to in site.xml.

I did try that and created an example markdown page under src/site/markdown and a site.xml under src/site. The markdown page is successfully translated to html.

enter image description here

However, during the execution of the maven-site-plugin plugin the index.html seems to be overwritten. The "old" project information is missing (despite the fact that the html pages are still created) and only my new minimalistic page is shown

problem

Does anybody have an idea how to fix that? I would like all the stuff in the first image as well as a Overview menu with custom content


MWE

pom.xml

<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    ...
    
    <!-- PROPERTIES -->
    <properties>
        ...
        <maven.plugin.project-info-reports.version>3.4.4</maven.plugin.project-info-reports.version>
        <maven.plugin.site.version>4.0.0-M8</maven.plugin.site.version>
        ...
        <jacoco.version>0.8.10</jacoco.version>
        <maven.plugin.checkstyle.version>3.3.0</maven.plugin.checkstyle.version>
        <maven.plugin.javadoc.version>3.5.0</maven.plugin.javadoc.version>
        <maven.plugin.jxr.version>3.3.0</maven.plugin.jxr.version>
        <maven.plugin.surefire.version>3.1.0</maven.plugin.surefire.version>
        ...
    </properties>
    
    ...
    
    <build>
        <pluginManagement>
            <plugins>
                
                <!-- Site info -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${maven.plugin.site.version}</version>
                    <configuration>
                        <skip>${maven.plugin.site.skip}</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>site</id>
                            <phase>install</phase>
                            <goals>
                                <goal>site</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                
                <!-- Projects info -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>${maven.plugin.project-info-reports.version}</version>
                </plugin>
                
                <!-- Generate the JavaDoc -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven.plugin.javadoc.version}</version>
                    ...
                <plugin>
                
                ...
            </plugins>
        </pluginManagement>
        
        <!-- PLUGINS -->
        <plugins>
        
            ...
            
            <!-- Site info -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
            </plugin>
                
            <!-- Projects info -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
            </plugin>
            
            ...
            
            <!-- Code coverage -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                ...
            </plugin>
        </plugins>
        
    </build>
    
    <!-- REPORTING -->
    <reporting>
        
        <plugins>
            <!-- Surefire test report -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${maven.plugin.surefire.version}</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/site</outputDirectory>
                    <reportsDirectories>
                        <reportsDirectories>${project.build.directory}/surefire-reports</reportsDirectories>
                    </reportsDirectories>
                    <linkXRef>false</linkXRef>
                </configuration>
                <reportSets>
                    <reportSet>
                        <id>integration-tests</id>
                        <reports>
                            <report>report-only</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            
            <!-- Code Coverage report -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            
            <!-- JavaDoc report -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <outputDirectory>${project.build.directory}/apidocs</outputDirectory>
                    <reportOutputDirectory>${project.reporting.outputDirectory}/apidocs</reportOutputDirectory>
                    <author>${maven.plugin.javadoc.author}</author>
                    <!-- Use MathJax for LaTeX in JavaDoc -->
                    <additionalparam>-header '&lt;script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"&gt;&lt;/script&gt;'</additionalparam>
                    <show>${maven.plugin.javadoc.show}</show>
                    <!-- Disable all missing warnings -->
                    <doclint>all,-missing</doclint>
                    <quiet>${maven.plugin.javadoc.quiet}</quiet>
                </configuration>
                <reportSets>
                    <reportSet><!-- by default, id = "default" -->
                        <reports><!-- select non-aggregate reports -->
                            <report>javadoc</report>
                            <!--<report>test-javadoc</report>-->
                        </reports>
                    </reportSet>
                    <reportSet><!-- aggregate reportSet, to define in poms having modules -->
                        <id>aggregate</id>
                        <inherited>false</inherited><!-- don't run aggregate in child modules -->
                        <reports>
                            <report>aggregate</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            
            <!-- Checkstyle report -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven.plugin.checkstyle.version}</version>
                <configuration>
                    <cacheFile>${project.build.directory}/checkstyle/checkstyle-cachefile</cacheFile>
                    <outputFile>${project.build.directory}/checkstyle/checkstyle-result.xml</outputFile>
                    <rulesFile>${project.build.directory}/checkstyle/checkstyle-rules.xml</rulesFile>
                    <!--<checkstyleXmlOutputDirectory>${project.build.directory}/site</checkstyleXmlOutputDirectory>-->
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>checkstyle</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            
            <!-- JXR report -->
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jxr-plugin</artifactId>
              <version>${maven.plugin.jxr.version}</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>jxr-no-fork</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
    
</project>

site.xml

<project xmlns="http://maven.apache.org/SITE/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 http://maven.apache.org/xsd/site-2.0.0.xsd"
         name="Content">     <!-- name attribute defines title of the site -->
    
    <!-- Enable Fluido skin -->
    <skin>
        <groupId>org.apache.maven.skins</groupId>
        <artifactId>maven-fluido-skin</artifactId>
        <version>2.0.0-M6</version>
    </skin>
    
    <body>
        <!-- Add links to pages to menu -->
        <menu name="Overview">
            <item name="Another Page" href="sample.html" />
        </menu>
    </body>

</project>

sample.md

# Sample page
0

There are 0 best solutions below