I have:
1. Gradle 1.6
2. SonarQube instance 5.0 (also have 4.1+ instances)
3. sonar-runner (aka SonarQube runner) version: 2.4
4. Groovy Version: 2.3.3 JVM: 1.7.0_40 Vendor: Oracle Corporation OS: Linux
I have project's with Java, Java + Groovy or totally Groovy based project. All of these projects have valid Unit and non-Unit tests (Integration, Selenium etc). I'm also running various static analysic tools for both Java/Groovy (pmd, findbugs, checkstyle, codenarc etc).
For a Java based project, when I run sonarRunner (Gradle task) OR sonar-runner, I see valid data in project's Sonar dashboard for everything (including combined code coverage and other project health info). So, everything works for a JAVA based project.
The same though, is not working for a Groovy based project. i.e. when I pass "sonar.language=grvy" for a Groovy based project and run Sonar analysis, I do NOT get Unit and IT test coverage as it says 0% coverage OR it doesn't even LIST those in Sonar project's dashboard but I successfully get project health info (issues, lines of code, etc etc).
When I pass the above sonar language variable as "sonar.language=java" for this Groovy project, I do NOT see Groovy project's data info (issues, lines of code etc etc) and any code coverage info for Unit / Integration tests and their combined tests. I have valid jacoco exec files for both Unit tests and Integration tests (jacocoIT.exec is created after jacocoagent is attached to the target Tomcat JVM and after Tomcat instance is stopped).
Any ideas! why sonar is not working for a Groovy based project OR for a project which has both Java+Groovy (source Java, tests in Groovy or vice versa or mixed).
PS: I tried sonar.language=grvy,java OR sonar.language=java,grvy BUT, it didn't make any improvement on the project's sonar dashboard.
The latest SonarQube version that I have (5.0) does support multiple language support.
Sonar's Project Motion Chart plugin also doesn't show any info as well even though Lines of Code is showing up at the right side (when sonar.languages is passed as grvy).
When I pass sonar.language=java I get, here Project Motion Chart is showing nothing (not even a blank graph) says "No Data". All other project health related info is gone too (Technical debt etc fields says 0):
With the latest SonarQube version, I see there are new sonar.*.* fields and I'm trying to find if I'm missing to provide a field or it's correct value.
OK.. what happens??? when I use SonarQube instance version 4.1.2 (instead of 5.0)
When I use sonar.language=java I see some info and Unit test coverage says 0% but Unit test success says 100% successful. Even though I have valid jacoco IT exec file for Integratiojn tests, it still not showing that widget info.
When SonarQube instance is 4.1.2 and if I set sonar.language=grvy, I do NOT see any Unit tests coverage or IT coverage of state of tests being successful % at all:
This is what I have in my project's sonar-project.properties file (when I use sonar-runner utility).
sonar.projectName=GradlePlugin
sonar.projectKey=com:company:projectABC:GradlePlugin
sonar.projectVersion=1.0
# optional description
sonar.projectDescription=ContainerSvc Business Service
#sonar.language=grvy,java
sonar.language=java
#Tells SonarQube that the code coverage tool by unit tests is JaCoCo
sonar.java.coveragePlugin=jacoco
#Tells SonarQube to reuse existing reports for unit tests execution and coverage reports
sonar.dynamicAnalysis=reuseReports
#Tells SonarQube where the unit tests execution reports are
sonar.surefire.reportsPath=build/test-results/UT
# Some properties that will be inherited by the modules
#sonar.sources=src/main/groovy,src/main/java,src/test/java,src/test/groovy,src/java-test,src/groovy-test
# Sonar Unit Test Report path
sonar.jacoco.reportPath=build/jacoco/UT/jacocoUT.exec
# Sonar Integration Test Report Path
#sonar.jacoco.itReportPath=build/jacoco/IT/jacocoIT.exec
sonar.jacoco.itReportPath=build/jacoco/UT/jacocoUT.exec
# Sonar Binaries
sonar.binaries=build/classes/main
sonar.java.binaries=build/classes/main
sonar.groovy.binaries=build/classes/main
sonar.sources=src/main/groovy
sonar.tests=src/test/groovy
# Encoding of the source code
sonar.sourceEncoding=UTF-8
sonar.scm.url=scm:svn:http://kobaloki/Core/GradlePlugin/trunk
sonar.junit.reportsPath=build/test-results/UT
sonar.java.coveragePlugin=jacoco
sonar.groovy.coveragePlugin=jacoco
sonar.grvy.coveragePlugin=jacoco
I used/tweaked the above values many time with different values while running sonar-runner.
I used the same values with -D / -P parameters when I run sonarRunner task in Gradle.
Note: SonarQube 5.0 won't work with Gradle (1.6) version (that I'm using) as I get an error about "Failed to download Libraries" etc. (this error won't come if I use Gradle > 2.2 version).
One other point I noticed is that, even though I'm using Groovy compile option debug=true for compiling both Groovy project's source and tests code, while doing sonar-runner (with both SonarQube instance 4.1.2 or 5.0 isntances) --or running sonarRunner Gradle task (with 4.1.2), I see the following lines in the analysis output.
15:32:20.647 INFO - Analysing /production/jenkins/AKS/ma/GradlePlugin/build/jacoco/IT/jacocoIT.exec
15:32:21.025 WARN - Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?
and
15:32:24.681 INFO - Analysing /production/jenkins/AKS/ma/GradlePlugin/build/jacoco/UT/jacocoUT.exec
15:32:24.791 WARN - Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?
15:32:24.792 INFO - Sensor JaCoCoSensor done: 112 ms