2

I use scoverage for reporting coverage information for my scala code base. I am kind of new to the Java stack, but I have worked in environments, where a coverage build differed from the release build (by introducing additional information into the compiled artifacts) and a subsequent clean and rebuild step was necessary.

Now I am unsure what the situation is with an scoverage scala project.

So: After mvn scoverage:report should I run a mvn clean before my mvn package command on the CI server?

wirrbel
  • 3,173
  • 3
  • 26
  • 49

2 Answers2

3

When you're running commands with maven (build, package, scoverage:report, etc.), all needed intermediate information is stored in the target folder (by default, you can change this behaviour if you need), and should not affect any other phases unless they are designed that way.

So it is not required to run mvn clean in case you've described. Resulted jar file will be the same with or without clean.

If you want to have a jar file with SCoverage instrumented classes, you can do it with the running mvn scoverage:package (check here). Even if you will run commands one after another in a way:

mvn clean
mvn scoverage:report
mvn scoverage:package
mvn package

in the end you'll get two jar files in your target folder:

app.jar
scoverage-app.jar

where app.jar will be without any scoverage information.

3

As mentioned in the scoverage-maven-plugin documentarion here:

We don't want to accidentally deploy these instrumented classes, so SCoverage keeps them separate. SCoverage does this by forking the current Maven build and running it again, while performing instrumentation.

So the instrumented classes will be kept separated using this fork mechanism. Also, in that documentation you have the configuration required to replace your normal unit test execution with the scoverage tests, so you will not have to run your unit tests twice (and still getting the forked scoverage execution with instrumented classes separated).

What that means is that you should not require to run clean again, and you can check in the target folder that scoverage classes are stored separately in the scoverage-classes directory.

Selnay
  • 699
  • 4
  • 16