scalamavenscoverage

Scala/scoverage: Is it necessary to make a clean rebuild for releasing a jar for publishing?


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?


Solution

  • 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.