Mill plugin to collect test coverage data with JaCoCo and generate reports.
You need at least Mill 0.9.7 to use mill-jacoco.
To enable coverage data generation with JaCoCo, add the JacocoTestModule to your test module.
build.mill (Mill 1.0.6)//| mill-version: 1.0.6
//| mvnDeps: [ "de.tototec::de.tobiasroeser.mill.jacoco::0.1.0" ]
package build
import mill.*
import mill.scalalib.*
import de.tobiasroeser.mill.jacoco.JacocoTestModule
object main extends JavaModule {
object test extends JavaTests with JacocoTestModule
}To generate JaCoCo reports, run:
> mill de.tobiasroeser.mill.jacoco.Jacoco/jacocoReportFullYou can override the JacocoReportModule.jacocoVersion task or define the JACOCO_VERSION environment variable.
> mill show de.tobiasroeser.mill.jacoco.Jacoco/jacocoVersion
"0.8.14"
> JACOCO_VERSION=0.8.13 mill show de.tobiasroeser.mill.jacoco.Jacoco/jacocoVersion
"0.8.13"By default, a preconfigured external Mill module is used to collect all coverage data.
If you want to collect more than one data set, e.g. to separate unit test and integration test coverage data, you can define your own instances of JacocoReportModule instead of using the pre-configured external module de.tobiasroeser.mill.jacoco.Jacoco.
//| mill-version: 1.0.6
//| mvnDeps: [ "de.tototec::de.tobiasroeser.mill.jacoco::0.1.0" ]
package build
import mill.*
import mill.scalalib.*
import de.tobiasroeser.mill.jacoco.JacocoTestModule
object jacocoUnit extends JacocoReportModule {
protected override lazy val millDiscover: Discover = Discover[this.type]
}
object jacocoIntegration extends JacocoReportModule {
protected override lazy val millDiscover: Discover = Discover[this.type]
}
object main extends JavaModule {
object test extends JavaTests with JacocoTestModule {
override def jacocoReportModule = ModuleRef(jacocoUnit)
}
object integrationTest extends JavaTests with JacocoTestModule {
override def jacocoReportModule = ModuleRef(jacocoIntegration)
}
}> mill __.test # Run all tests
> mill jacocoUnit.jacocoReportFull # Generate coverage report for unit tests
> mill jacocoIntegration.jacocoReportFull # Generate coverage report for integration testsBinary releases of this plugin can be downloaded from Maven Central.
Please make sure to use the correct Mill Platform Suffix, matching your used Mill version:
-
_mill1_3for Mill 1.x
-
_mill0.11_2.13for Mill 0.11.x and 0.12.x
-
_mill0.10_2.13for Mill 0.10.x
-
_mill0.9_2.13for Mill 0.9.x
Mill does this automatically for you, if you use a :: after the artifact name in the dependency declaration, e.g. "de.tototec::de.tobiasroeser.mill.jacoco::0.1.0"
This project is published under the Apache License, Version 2.0.
- mill
-
Mill is a Scala-based open source build tool. In my opinion the best build tool for the JVM. It is fast, reliable and easy to understand.
- me
-
I am a professional software developer and love to write and use open source software. I’m actively developing and maintaining Mill as well as several mill plugins.
If you like my work, please star it on GitHub. You can also support me via GitHub Sponsors.
- Contributing
-
If you found a bug or have a feature request, please open a new issue on GitHub. I also accept pull requests on GitHub.
-
Better detect Mill test modules to exclude their files / classes from coverage reports. Requires at least Mill
0.11.7.