Skip to content

Commit

Permalink
Merge pull request #3 from iniweb/feature/sonar_jacoco_coverage
Browse files Browse the repository at this point in the history
JaCoCo code coverage
  • Loading branch information
nickdgriffin committed Apr 22, 2016
2 parents 95eba14 + d1198ee commit e3c2a0d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

<cobertura.version>2.7</cobertura.version>

<jacoco.version>0.7.5.201505241946</jacoco.version>
<jacoco.path>${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar</jacoco.path>
<jacoco.utReport>${project.build.directory}/jacoco.exec</jacoco.utReport>
<jacoco.utAgentConfig>-javaagent:${jacoco.path}=destfile=${jacoco.utReport}</jacoco.utAgentConfig>
<jacoco-listeners.version>3.5</jacoco-listeners.version>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -271,6 +277,20 @@
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>

<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>${jacoco-listeners.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Maven plugin versions are mentioned in order to guarantee the build reproducibility in the long term -->
Expand Down Expand Up @@ -305,9 +325,23 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<!-- JDK 7 - relax bytecode verifier to prevent double -->
<!-- instrumentation issues with OpenJPA tests and JaCoCo -->
<!-- <argLine>-XX:-UseSplitVerifier ${jacoco.utAgentConfig}</argLine> -->
<!-- JDK 8 - bytecode verifier cannot be relaxed or disabled -->
<!-- to prevent runtime errors, OpenJPA tests are ignored -->
<argLine>${jacoco.utAgentConfig}</argLine>
<includes>
<include>**/*Tests.java</include>
</includes>
<properties>
<!-- add SonarQube's JaCoCo listener to enable -->
<!-- gathering of code coverage metrics per test -->
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
Expand Down
13 changes: 11 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src
sonar.sources=src/main/java

# Language
sonar.language=java

# Comma-separated paths to directories with tests
sonar.tests=src/test/java

# Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files
sonar.java.binaries=target/classes

# Tells SonarQube where the unit tests code coverage report is
sonar.jacoco.reportPath=target/jacoco.exec

# Encoding of the source files
sonar.sourceEncoding=UTF-8
sonar.sourceEncoding=UTF-8

0 comments on commit e3c2a0d

Please sign in to comment.