scoverage-maven-plugin is a plugin for Maven that integrates the scoverage code coverage library. Find out more about scoverage.
In short:
-
check goal compiles classes with instrumentation, runs unit tests and checks coverage,
-
report goal compiles classes with instrumentation, runs unit tests and generates reports,
-
integration-check goal (new in 1.1.0-SNAPSHOT) compiles classes with instrumentation, runs unit and integration tests and checks coverage,
-
integration-report goal (new in 1.1.0-SNAPSHOT) compiles classes with instrumentation, runs unit and integration tests and generates reports,
-
check-only goal only checks coverage using coverage data generated earlier in the build (e.g. by report goal).
-
report-only goal generates reports using coverage data generated earlier in the build (in most cases by check goal),
-
pre-compile and post-compile are internal goals, don't use them,
Maven generated plugin documentation:
Version | Documentation |
---|---|
1.0.4 | Plugin Info |
1.1.0-SNAPSHOT | Plugin Info |
Plugin is compatible with two Maven Scala compiler plugins:
-
SBT Compiler Maven Plugin - version 1.0.0-beta5 or later required,
-
Scala Maven Plugin - version 3.0.0 or later required, addScalacArgs and analysisCacheFile configuration parameters cannot be set directly, use project properties 'addScalacArgs' and 'analysisCacheFile' instead.
This can be set as project property.
<project> <properties> <scoverage.plugin.version>1.0.4</scoverage.plugin.version> </properties> </project>
Plugin supports Scala 2.10.x and 2.11.x versions by automatically loading and configuring scalac-scoverage-plugin_2.10 or scalac-scoverage-plugin_2.11 Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining "scalaVersion" plugin configuration parameter or "scala.version" project property. Without this setting, coverage will not be calculated.
<project> <properties> <scala.version>2.11.4</scala.version> </properties> </project>
or
<project> <build> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <configuration> <scalaVersion>2.11.4</scalaVersion> <-- other parameters --> </configuration> </plugin> </plugins> </build> </project>
The first method is better because once the property is defined it's value can be used in other places of the build file. For example in scala-library dependency version every Scala build should declare.
<project> <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.version}</version> </dependency> </dependencies> </project>
Maven SCoverage plugin uses by default the latest version of the scalac-scoverage-plugin available on its release day. If newer, better version of scalac-scoverage-plugin is available, it can be used instead. It can be configured by defining "scalacPluginVersion" plugin configuration parameter or "scoverage.scalacPluginVersion" project property.
<project> <properties> <scoverage.scalacPluginVersion>1.0.4</scoverage.scalacPluginVersion> </properties> </project>
or
<project> <build> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <configuration> <scalacPluginVersion>1.0.4</scalacPluginVersion> <-- other parameters --> </configuration> </plugin> </plugins> </build> </project>
Just add it to reporting section of your project.
<project> <reporting> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> </plugin> </plugins> </reporting> </project>
If you want to customize plugin's configuration parameters used by compilation supporting part of the plugin, do it in 'plugins' or 'pluginManagement' section:
<project> <build> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <configuration> <highlighting>true</highlighting> <!-- example configuration for Play! Framework 2.x project --> <excludedPackages>views.html.*</excludedPackages> <excludedFiles>.*?routes_(routing|reverseRouting)</excludedFiles> </configuration> </plugin> </plugins> </build> </project>
Read SBT SCoverage Plugin documentation for more information about highlighting and excludedPackages.
There are no configuration parameters for report generating part of the plugin, so no configuration should be added inside 'reporting' section.
<project> <build> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <configuration> <minimumCoverage>80</minimumCoverage> <failOnMinimumCoverage>true</failOnMinimumCoverage> </configuration> <executions> <execution> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
Read SBT SCoverage Plugin documentation for more information.
<project> <build> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <configuration> <minimumCoverage>80</minimumCoverage> <failOnMinimumCoverage>true</failOnMinimumCoverage> </configuration> <executions> <execution> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.scoverage</groupId> <artifactId>scoverage-maven-plugin</artifactId> <version>${scoverage.plugin.version}</version> <reportSets> <reportSet> <reports> <report>report-only</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting> </project>
There are many example projects. Go to one of them and run mvn site
.
This software is licensed under the Apache 2 license, quoted below. Copyright 2014-2015 Grzegorz Slowikowski Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.