Reputation: 3799
I'm writing an application whose target classes (in src/main/java) are written / compiled to Java 7 but whose unit tests (in src/test/java) are written in Groovy. I am trying to get metrics from Sonarqube when I run mvn sonar:sonar
. I get most everything, but I don't get code coverage metrics from JaCoCo. Instead I get the following message when the runner gets to the JaCoCo sensor:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: C:\Users\fiddlerpianist\Projects\emailnotifier\target\jacoco.exec
However, when I run the EclEmma coverage (which uses JaCoCo) inside of Eclipse, I get full coverage reports with these Groovy tests. It just doesn't work through Sonarqube. Does anyone know why it doesn't work, or if there is a way I can configure something differently to make it work? I've tried a bunch of permutations of configuration, but so far... no luck.
The Maven java compiler plugin I'm using is configured a little differently (i.e. I use lombok):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<javaAgentClass>lombok.core.Agent</javaAgentClass>
</compilerArguments>
<fork>true</fork>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.7.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.0.8-01</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.12.6</version>
</dependency>
</dependencies>
</plugin>
And I have my Groovy dependency scoped as test
:
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
</dependencies>
I'm using Sonarqube 3.7.4, Maven 3.1.1, Groovy 2.0.8, and Java 7. I'm using all the defaults for the Sonar Maven plugin (version 2.2).
Upvotes: 0
Views: 3962
Reputation: 3799
So it turns out that you have to have at least one file with the .java
extension (doesn't even have to be a test) in the src/test/java
folder, and then everything works. It reminds me of a Groovy integration bug with Maven that used to require one Java file in with your Groovy code, but they since fixed that.
Upvotes: 1