3

I have generated a clover.xml report for my service. I want to integrate that with my SonarQube report which is not showing the coverage at all. I am not sure what exact plugin to add to my pom.xml so sonar can read it. Here is part of my pom.xml:

<plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>2.7.1</version>
                    <executions>
                        <execution>
                            <id>add-test-source</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>add-test-source</goal>
                            </goals>
                            <configuration>
                                <sources>
                                    <source>src/it/java</source>
                                </sources>
                            </configuration>
                        </execution>
                    </executions></plugin><plugin>
    <groupId>com.atlassian.maven.plugins</groupId>
    <artifactId>maven-clover2-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>**/*Constants.java</exclude>       
                    <exclude>**/*LatestTimeSeriesDataServiceImpl.java</exclude>
                    <exclude>**/TestWebRequest.java</exclude>
                </excludes>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
                <sonar.clover.reportPath>target\site\clover\clover.xml</sonar.clover.reportPath>
                <sonar.surefire.reportsPath>target\surefire-reports</sonar.surefire.reportsPath>
                <sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
                <sonar.clover.version>${clover.version}</sonar.clover.version>
            </configuration>

and this is part of my setting.xml:

<id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <sonar.jdbc.url></sonar.jdbc.url>
            <sonar.jdbc.driver></sonar.jdbc.driver>
            <sonar.jdbc.username></sonar.jdbc.username>
            <sonar.jdbc.password></sonar.jdbc.password>
            <sonar.host.url>http://localhost:9000/</sonar.host.url>
    </properties>

I hided some values I am not sure if they are confidential or not..

these are the values to my sonar-project.properties:

sonar.projectKey=org.sonarqube:java
sonar.projectName=org.sonarqube:java
sonar.projectVersion=1.0
sonar.sources=path
sonar.tests=path
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.core.codeCoveragePlugin=clover
sonar.clover.reportPath=target/site/clover/clover.xml
sonar.java.binaries=target/classes
sonar.dynamicAnalysis=reuseReports

in addition i tried to enforce the properties through command line as well:

mvn sonar:sonar -s menlo_settings.xml -Dsonar.host.url=http://localhost:9000/ org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar -Dsonar.core.codeCoveragePlugin=clover -Dsonar.clover.reportPath=target/site/clover/clover.xml

Nothing is working and I am frustrated!! If anyone know about it please let me know!

Maram Mutaieb
  • 51
  • 1
  • 2
  • First, please verify that 1) you have the Clover plugin installed 2) there are no errors in your analysis log. Also, does your analysis complete successfully? Does the project show up in SonarQube with everything but your Clover results? – G. Ann - SonarSource Team May 30 '17 at 14:10
  • Everything is showing up except for the coverage. I fixed this now by taking the coverage reports from jacoco but I was trying to enforce my clover reports but it did not work. – Maram Mutaieb May 31 '17 at 08:27
  • i documented a recipe to use with an Nx (13.4.1) Angular (13.1) Workspace using Jest to run unit tests and to generate and publish unit test run results and coverage reports to SonarQube server individually for each library https://stackoverflow.com/a/70530811/7085047 – Datum Geek Dec 30 '21 at 11:32

0 Answers0