Getting coverage 0% on upgrade to sonarquebe 8.3 with jacoco

I have a maven project in the following structure:
1 class under the project and 1 model with a class.
In both of them there are test classes:

-testProject
   -src
     -main
       -java
         Class2.java
     -test
      -java
        Test2.java
   -Infra Module
    -src
      -main
       -java
         Class1.java
       -test
         -java
           Test1.java

in the main pom I configure jacoco plugin:

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.5</version>
                    <executions>
                        <execution>
                            <id>prepare-agent</id>
                            <phase>initialize</phase>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>*</include>
                                </includes>
                            </configuration>
                        </execution>
                        <execution>
                            <id>report</id>
                            <goals>
                                <goal>report-aggregate</goal>
                            </goals>
                            <phase>verify</phase>
                        </execution>
                    </executions>
                </plugin>

and also I configure in properties the xmlReportsPath:

<sonar.coverage.jacoco.xmlReportPaths>{project.basedir}/target/site/jacoco-aggregate/jacoco.xml, {project.basedir}/infra/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>

I run:
mvn clean verify sonar:sonar

I get 0% coverage and error that scoverage.xml file is not found.
The jacoco.xml files are not containing information on tests that were run.

Also, the warning below which I think is not correlated to the problem:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/navap/.sonar/cache/54f6535c111cefad0fb6a09ba3e61922/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byt
e,int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

What is wrong?
Thank you,
Nava Polak Onik.

Hi,

This should help:

 
Ann

I already noticed this information.
I don’t use the sonar.jacoco.reportPath
I have added sonar.coverage.jacoco.xmlReportPaths.
The problem is the jacoco.xml file does not contain any run information although tests were running.
Any idea?

Hi,

Sorry, but this is a JaCoCo-specific question & I have no expertise there.

 
:woman_shrugging:
Ann

Finally I was able to find the root cause of the problem.
In version 7.9 we were using the jacoco plugin inside a maven profile and it worked well.
On version 8.3, sonar is not able to recognize the jacoco plugin inside a profile and this is why it is not working.
The reason to work with a profile is we don’t want the jacoco to run everytime we run a build. Just if we call the specific profile.
It is not a jcoco issue since the jacoco run well but a sonar issue since the sonar doesn’t recognize the jacoco configuration under profile.
It is a regression from version 7.9
Let me know if you need more details.

Regards,
Nava Polak Onik.

Hi Nava,

I’m glad you worked through this.

To be clear, SonarQube does not execute your tests not generate the reports.

 
Ann