After much trail and error, I finally was able to get Sonar, Jacoco, and Bamboo working harmoniously together. I documented the process here!, but I'll copy my solution here to ensure it's always available.
For my application, I actually used a sonar runner tasks. You have more explicit steps to install and configure the sonar-runner, which isn't mentioned in the install guide. First, you must install the sonar-runner and specify the following properties in your sonar-runner.properties:
#----- Default Sonar server
sonar.host.url=http://localhost:9000
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#sonar.jdbc.driver=org.postgresql.Driver
#----- Global database settings
sonar.jdbc.username=user
sonar.jdbc.password=passwd
Include the jacoco xmlns in your ant build script at the top:
<project basedir="." default="build" name="project" xmlns:jacoco="antlib:org.jacoco.ant">
<property environment="env" />
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="libs/independent/jacocoant.jar"/>
</taskdef>
Next, you have to add jacoco coverage to your ant build script:
<jacoco:coverage enabled="${tests.code.coverage}" destfile="${jacoco.exec.dest}">
<junit fork="yes" printsummary="withOutAndErr" dir="${tests.working.dir}">
...
Last, you need to tell sonar, from bamboo, to use jacoco results and reuse the reports generated in your build. You do this by adding the following properties to your "Custom Extra Parameters" in the Task configure for sonar analysis in the Bamboo Job. Configure the following options:
-DbuildNumber=${bamboo.buildNumber}
-Dsonar.core.codeCoveragePlugin=jacoco
-Dsonar.jacoco.reportPath=tests/jacoco-exec/jacoco.exec
-Dsonar.dynamicAnalysis=reuseReports
-Dsonar.surefire.reportsPath=tests/test-reports
Once I had all this configured, my test coverage started showing up in sonar with the # successful tests listed.
Just be sure you set the sunfire property to reuse their reports generated from your unit tests. Otherwise, sonar won't know where to find them even if you tell it to reuse reports. Hope that helps at your next attempt.