Why does sbt-scoverage report java.lang.RuntimeException: Duplicate mappings for JavaScript files?

796 Views Asked by At

I am using sbt-scoverage plugin for a project written in Play Framework.

I'm facing the following java.lang.RuntimeException: Duplicate mappings error:

[scoverage]: Instrumentation completed [35097 statements]
[scoverage]: Written instrumentation file [/Users/project/target/scala-2.10/scoverage-data/scoverage.coverage.xml]
[scoverage]: Writing measurements data to [/Users/project/target/scala-2.10/scoverage-data]
...
[info] Compiling 49 Scala sources to /Users/project/target/scala-2.10/test-classes...
java.lang.RuntimeException: Duplicate mappings:
/Users/project/target/scala-2.10/scoverage-classes/services-main.js
from
/Users/project/target/scala-2.10/resource_managed/main/public/javascripts/global/services/services-main.js
/Users/project/target/scala-2.10/resource_managed/main/public/javascripts/kiosk/global/services/services-main.js
/Users/project/target/scala-2.10/scoverage-classes/global.min.css
from......

My guess is that it's trying to transfer service-main.js from somewhere in the target under scoverage-classes. I do not intend to run scoverage against any JavaScript file so I included the following setting:

ScoverageKeys.excludedPackages in ScoverageCompile := ".views.;.javascripts.;.assets.;.js.;.resource_managed."

It changes nothing - the error persists. How do I instruct scoverage to ignore JavaScript files?

2

There are 2 best solutions below

0
On

This bug was fixed in release 1.0.0. Note that the config changed so be sure to check the readme (most notably, the command to run changed from sbt scoverage:test to sbt coverage test and the plugin became an auto plugin so you don't need to add instrumentSettings anymore).

https://github.com/scoverage/sbt-scoverage

0
On

It's just a guess, but worth pursuing to check if it fixes the issue.

According to Exclude classes and packages:

You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of regular expressions.

The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect.

Any matched classes will not be instrumented or included in the coverage report.

I think the regular expressions you use are incorrect and since they don't match they are of no effect. Use .* not . as follows:

ScoverageKeys.excludedPackages in ScoverageCompile := ".*javascripts.*;.*\.js"