sbtscoverage

Exclude plugin's libraryDependencies from released application when "package" in SBT


In my SBT project I use sbt-scoverage plugin. I did what the documentation says and added ScoverageSbtPlugin.instrumentSettings to build.sbt. Everything works great so far.

When I package my app I can see in pom.xml that there is a dependency that should not be there:

<dependency>
  <groupId>com.sksamuel.scoverage</groupId>
  <artifactId>scalac-scoverage-plugin</artifactId>
  <version>0.95.4</version>
</dependency>

This is a library dependency of the sbt-scoverage plugin that I don't want to have as a dependency in my released app.

I believe that this dependency is created by the following code in ScoverageSbtPlugin.scala:

libraryDependencies += "com.sksamuel.scoverage" %% "scalac-scoverage-plugin" %
    ScalacScoveragePluginVersion % scoverage.name

Can anyone tell me how to make this dependency to be added only when I run sbt scoverage:test?


Solution

  • I came to following solution. I have replaced this:

    ivyConfigurations ++= Seq(scoverage, scoverageTest)
    

    with this:

    ivyConfigurations ++= Seq(scoverage hide, scoverageTest hide)
    

    Here's the changeset: https://github.com/scoverage/sbt-scoverage/commit/6d7ebe07482933f588e9feb23f80eeed2aa14f62

    I would appreciate anybody's view on that. It works "on my machine".