Sonarqube not picking up jacoco.xml file

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

Sonarqube version : 10.5.0.89998

Using: Installed and ran sonarqube through brew.

Trying to analyze code coverage for my project
Tried configuring jacoco plugin and properties through pom.xml file.

properties defined as

 <properties>
        <java.version>1.8</java.version>
        <jacoco.version>0.8.6</jacoco.version>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
        <sonar.coverage.jacoco.xmlReportPaths>/Users/dhruv/Downloads/Projects/finance-consumer/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.language>java</sonar.language>
        <sonar.qualitygate.wait>true</sonar.qualitygate.wait>
    </properties>

dependency for unit test (junit 5)

 <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>

jacoco depndency

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

jacoco plugin

<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report-aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I am able to generate proper jacoco exec file and visualize it using jacoco.html file

Hey there.

What do the logs say about importing the coverage reports?

hi @Colin,

Please find the log lines below regarding the coverage report imports.

[INFO] 16:43:36.839 No "Generated" source files to scan.
[INFO] 16:43:36.839 Sensor JavaSensor [java] (done) | time=11906ms
[INFO] 16:43:36.839 Sensor JaCoCo XML Report Importer [jacoco]
[WARNING] 16:43:36.841 No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='/Users/dhruv/Downloads/Projects/finance-consumer/target/site/jacoco/jacoco.xml'. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
[INFO] 16:43:36.841 No report imported, no coverage information will be imported by JaCoCo XML Report Importer

but I don’t see what exactly is causing this issue.

Have you made sure this file exists?

You can try just a cat /Users/dhruv/Downloads/Projects/finance-consumer/target/site/jacoco/jacoco.xml in the terminal.

Actually I got the issue. the problem was with wrong directory structure. Herby I am attaching the screenshot for reference. After I restructured my application I was able to get the code coverage. Since there were two structures due ambiguity the jacoco file that was generated was not getting imported properly.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.