Skip to content

Commit 0a5a396

Browse files
committed
Update documentation for Scala 3
1 parent dcca557 commit 0a5a396

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@ is sticky. To turn it back off when you're done running reports, use the
4848
`coverageOff` command or reset `coverageEnabled` with `set coverageEnabled :=
4949
false`.
5050

51+
### Usage with Scala 3
52+
53+
In Scala 3, the compiler itself takes care of the work that was done in Scala 2 by a compiler plugin. Unfortunately, currently the sbt plugin doesn't apply the neccessary options automatically.
54+
However, you can easily do it yourself, and use the plugin to generate user-friendly reports.
55+
56+
1. Add the scoverage sbt plugin by appending this line to your `project/plugins.sbt`
57+
```scala
58+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0-M4")
59+
```
60+
61+
2. Compile your project with
62+
```scala
63+
Compile/compile/scalacOptions +=
64+
s"-coverage-out:target/scala-${scalaVersion.value}/scoverage-data"
65+
```
66+
You can also set `-sourceroot:PATHS_ROOT` to customize how the path of your source files are resolved.
67+
Note that `-sourceroot` also sets the root path of the SemanticDB files.
68+
69+
3. Run the tests: `sbt test`
70+
71+
4. Generate xml and html reports: `sbt coverageReport`
72+
73+
5174
### Multi project reports
5275

5376
By default, scoverage will generate reports for each project separately. You can

0 commit comments

Comments
 (0)