2

Jacoco reports are not generated when mvn builds the site.

Jacoco reports are generated in my target folder at target\site\jacoco , but somehow I am not able to see "Jacoco Tests" option under "Project Reports" when I try to build the jar site

The only thing I see in the log while generating the site is as below :

[INFO] <<< clirr-maven-plugin:2.6.1:clirr @ data-binding <<< 
[INFO] configuring report plugin com.cerner.engineering:maven-cerner-ml-dependency-plugin:1.1.1 
[INFO] configuring report plugin org.jacoco:jacoco-maven-plugin:0.7.4.201502262128
[INFO] Skipping JaCoCo execution due to missing execution data file:C:\MSVCWorkspace\br-hla-april-data-binding\target\jacoco.exec

I am using the command mvn clean install site

This is how I have configure jacoco in my pom.xml in my build section :

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.plugin.version}</version>
            <configuration>
               <excludes>
                  <exclude>**/*Suite*.java</exclude>
               </excludes>
               <forkCount>1</forkCount>
               <reuseForks>false</reuseForks>
               <argLine>-Xms64m -Xmx512m -XX:MaxPermSize=256M -enableassertions -XX:+HeapDumpOnOutOfMemoryError ${jacoco.argLine}</argLine>
               <junitArtifactName>junit:junit-dep</junitArtifactName>
            </configuration>
         </plugin>

Jacoco plugin is called like :

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <configuration>
                <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
                <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>jacoco.argLine</propertyName>
                        </configuration>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I am not sure what is causing this issue , not to generate Jacoco reports on my site.

Although I am able to see the below in my logs

[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (default-cli) @ data-binding ---

[INFO] argLine set to -javaagent:C:\\_repository\\org\\jacoco\\org.jacoco.agent\\0.7.4.201502262128\\org.jacoco.agent-0.7.4.201502262128-runtime.jar=destfile=C:\\target\\coverage-reports\\jacoco-unit.exec

Thanks !!!

Stacker1234
  • 187
  • 1
  • 2
  • 12
  • If the problem continues despite of applying the workarounds, you may have a look at my answer on [maven jacoco: not generating code coverage report](https://stackoverflow.com/questions/25395255/maven-jacoco-not-generating-code-coverage-report/71661614#71661614). – Murat Yıldız Mar 29 '22 at 12:03

1 Answers1

1

I was able to fix by calling plugin as below

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <configuration>
                <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>jacoco.argLine</propertyName>
                        </configuration>
                </execution>
            </executions>
        </plugin>
Stacker1234
  • 187
  • 1
  • 2
  • 12