I am using jacoco-maven-plugin v0.8.0 to generate test code coverage 
reports (and checks) to the build. This is working fine for normal dev 
builds, e.g. mvn clean install.

However we also need to include these reports in the Maven site that is 
generated and published that part is not working.

The build is a multi-module build and I see you have a link to some ways of 
creating an aggregated report, 
https://github.com/jacoco/jacoco/wiki/MavenMultiModule, however I am not to 
the part yet. Right now I'm just trying to get it to publish the individual 
reports in the site build.

The problem is that the site build is including JaCoCo but its labeled as 
JaCoCo 
Aggregate 
<file:///C:/git/ODIN/tip-and-cue-refactor/target/site/jacoco-aggregate/index.html>
 
on each of the modules (and parent) and each of these point to 
'target/site/jacoco-aggregate/index.html' however that folder does not 
exist. The actual generated report is at target/site/jacoco-ut/index.html.

How can I configure JaCoCo so that it reports the correct name and location 
for each report? I have tried various configuration options in the 
reporting section but to no avail. It seems hard coded to use 
ReportAggregateMojo when it should use ReportMojo and I need to provide the 
outputDirectory when used indirectly via the site plugin. I will include my 
config below.

build...

<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
            <!--
    Prepares the property pointing to the JaCoCo runtime agent which
    is passed as VM argument when Maven the Surefire plugin is executed.
-->
            <execution>
                <id>jacoco-pre-unit-test</id>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
                <configuration>
                    <!-- Sets the path to the file which contains the execution 
data. -->
                    
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                    <!--
                        Sets the name of the property containing the settings
                        for JaCoCo runtime agent.
                    -->
                    <propertyName>surefireArgLine</propertyName>
                </configuration>
            </execution>

            <!--
    Ensures that the code coverage report for unit tests is created after
    unit tests have been run.
-->
            <execution>
                <id>jacoco-post-unit-test</id>
                <phase>test</phase>
                <goals>
                    <goal>report</goal>
                    <!--<goal>report-aggregate</goal>-->
                </goals>
                <configuration>
                    <!-- Sets the path to the file which contains the execution 
data. -->
                    
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                    <!-- Sets the output directory for the code coverage 
report. -->
                    
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                </configuration>
            </execution>

            <!--Ensures that the build has a minimum level of test coverage-->
            <execution>
                <id>jacoco-check</id>
                <phase>test</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                    <haltOnFailure>true</haltOnFailure>
                    <rules>
                        <rule 
implementation="org.jacoco.maven.RuleConfiguration">
                            <!--BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD-->
                            <element>BUNDLE</element>
                            <limits>
                                <limit 
implementation="org.jacoco.report.check.Limit">
                                    <!--INSTRUCTION, LINE, BRANCH, COMPLEXITY, 
METHOD, CLASS-->
                                    <counter>INSTRUCTION</counter>
                                    <!--TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, 
COVEREDRATIO, MISSEDRATIO-->
                                    <value>COVEREDRATIO</value>
                                    
<minimum>${jacoco.percentage.instruction}</minimum>
                                </limit>
                                <limit 
implementation="org.jacoco.report.check.Limit">
                                    <!--INSTRUCTION, LINE, BRANCH, COMPLEXITY, 
METHOD, CLASS-->
                                    <counter>BRANCH</counter>
                                    <!--TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, 
COVEREDRATIO, MISSEDRATIO-->
                                    <value>COVEREDRATIO</value>
                                    
<minimum>${jacoco.percentage.branch}</minimum>
                                </limit>                                
                            </limits>
                        </rule>
                    </rules>
                </configuration>
            </execution>

            <!-- The Executions required by unit tests are omitted. -->
            <!--
                Prepares the property pointing to the JaCoCo runtime agent which
                is passed as VM argument when Maven the Failsafe plugin is 
executed.
            -->
            <execution>
                <id>jacoco-pre-integration-test</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
                <configuration>
                    <!-- Sets the path to the file which contains the execution 
data. -->
                    <destFile>${jacoco.it.execution.data.file}</destFile>
                    <!--
                        Sets the name of the property containing the settings
                        for JaCoCo runtime agent.
                    -->
                    <propertyName>failsafeArgLine</propertyName>
                </configuration>
            </execution>
            <!--
                Ensures that the code coverage report for integration tests 
after
                integration tests have been run.
            -->
            <execution>
                <id>jacoco-post-integration-test</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>report</goal>
                    <!--<goal>report-integration</goal>-->
                </goals>
                <configuration>
                    <!-- Sets the path to the file which contains the execution 
data. -->
                    <dataFile>${jacoco.ut.execution.data.file}</dataFile>
                    <!-- Sets the output directory for the code coverage 
report. -->
                    
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                </configuration>
            </execution>

        </executions>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.15</version>
        <configuration>
            <!-- Sets the VM argument line used when unit tests are run. -->
            <argLine>${surefireArgLine}</argLine>
            <!-- Skips unit tests if the value of skip.unit.tests property is 
true -->
            <skipTests>${skip.unit.tests}</skipTests>
            <!-- Excludes integration tests when unit tests are run. -->
            <excludes>
                <exclude>**/IT*.java</exclude>
            </excludes>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.15</version>
        <executions>
            <!--
                Ensures that both integration-test and verify goals of the 
Failsafe Maven
                plugin are executed.
            -->
            <execution>
                <id>integration-tests</id>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
                <configuration>
                    <!-- Sets the VM argument line used when integration tests 
are run. -->
                    <argLine>${failsafeArgLine}</argLine>
                    <!--
                        Skips integration tests if the value of 
skip.integration.tests property
                        is true
                    -->
                    <skipTests>${skip.integration.tests}</skipTests>
                </configuration>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7</version>
    </plugin>


reporting...

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.0</version>
</plugin>


Note I'm not running IT tests yet. But ideally when we do I'd like to be 
able to publish both sets of reports in the site.


My command line to generate the site is mvn clean package site

-Dave

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/7fdb5bdb-7c49-4fb4-b400-e9517bcf3662%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to