Sonar+jacoco coverage showing 0% on ant java project

Hi Morning,

I am using below for my sonar-jacoco-coverage but it always show 0%

https://cp4d-sonarqube.svl.ibm.com/sonar
SonarQube™ technology is powered by SonarSource SA

  • Enterprise Edition
  • Version 8.2 (build 32929)
    sonar-jacoco-plugin-1.1.0.898.jar
    sonarqube-ant-task-2.6.0.1426.jar
    sonar-scanner-cli-4.0.0.1744.jar

Screenshot 2020-05-11 at 7.53.58 PM

when i run analysis i see all the results…but the coverage always shows 0%.
i am using ant java project for my product.
earlier for community edition it was showing. Recently we moved to enterprise edition when we moved only scanning or analysis is done but not the coverage.

have also attached the build.xml file to show the property used for our project.

pls help me on this.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Execute SonarScanner for Ant Analysis -->
<sonar:sonar/>
   <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
     <classpath path="lib/jacocoant.jar" />
   </taskdef>

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve thislogs.txt (455.1 KB)

can anyone pls help on this issue

can anyone pls help on this issue

Hi,

From your initial Ant excerpt, I don’t see where you’re generating the coverage report, and more importantly where you’re passing it in to analysis.

 
HTH,
Ann

P.S. Don’t forget that this is a community made up of people who come to help others out in their spare time. Sometimes you luck out and get an answer quickly, but that’s the exception rather than the rule.

pls find the paramters

<!-- Execute SonarScanner for Ant Analysis -->
<sonar:sonar/>
   <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
     <classpath path="/root/jacoco/lib/jacocoant.jar" />
   </taskdef>

i also tried using below

still coverage showing 0%

Hi,

Once you figure out how to generate the coverage report, you’ll need to pass it in to analysis. According to the docs, the property for that is sonar.coverage.jacoco.xmlReportPaths.

Also, it looks like you need to review the SonarScanner for Ant docs for how to analyze with Ant.

 
Ann

Hi Ann,

apologies for the late reply…

my ant issue got fixed.

but code coverage still shows 0%

!-- Define the SonarQube project properties -->
<property name="sonar.projectKey" value="XXXXXX" />
<property name="sonar.projectName" value="XXXXX" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.sources" value="src" />
<property name="sonar.tests" value="test" />
<property name="sonar.java.binaries" value="jacoco_instrumented" />
<property name="sonar.java.test.binaries" value="test_bin" />
<property name="sonar.java.libraries" value="lib/*.jar" />
<property name="sonar.java.test.libraries" value="dist/*.jar" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.java.source" value="1.7" />
<property name="sonar.coverage.exclusions" value = "**/*.html,**/*.css,**/*.png,**/*.jpg,**/*.JPG" />

<!-- <property name="sonar.jacoco.reportPaths" value="/root/git/liger-solserver-service/ilg-sol-workflow/jacoco.exec" /> -->
<property name="sonar.coverage.jacoco.xmlReportPaths" value="/root/git/liger-solserver-service/ilg-sol-workflow/report/jacoco-report.xml" />
<property name="sonar.junit.reportPaths" value="/root/git/liger-solserver-service/ilg-sol-workflow/report" /> 

<!-- Define SonarScanner for Ant Target -->
<target name="sonar">
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <!-- Update the following line, or put the "sonarqube-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
        <classpath path="lib/sonarqube-ant-task-2.6.0.1426.jar" />
    </taskdef>

<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
         <classpath path="lib/jacocoant.jar" />
       </taskdef>

    <!-- Execute SonarScanner for Ant Analysis -->
    <sonar:sonar/>
</target>

when i run target ant build.xml sonar

dont see any error…

Hi,

It looks like you’re providing absolute paths to your reports. Try making them relative from project root.

 
Ann

Hi,
i tried with relative path but still the same issue

Hi,

Please provide a code-formatted (``` on the line before and on the line after) excerpt of your analysis log showing where the report is being read.

 
Ann