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%
SonarQube™ technology is powered by SonarSource SA

  • Enterprise Edition
  • Version 8.2 (build 32929)

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 -->
   <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
     <classpath path="lib/jacocoant.jar" />

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


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.


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 -->
   <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
     <classpath path="/root/jacoco/lib/jacocoant.jar" />

i also tried using below

still coverage showing 0%


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.


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="" value="jacoco_instrumented" />
<property name="" value="test_bin" />
<property name="" value="lib/*.jar" />
<property name="" value="dist/*.jar" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="" value="jacoco" />
<property name="" 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-" />

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

    <!-- Execute SonarScanner for Ant Analysis -->

when i run target ant build.xml sonar

dont see any error…


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


i tried with relative path but still the same issue


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.