Skip to content

lefou/mill-jacoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mill-jacoco - Coverage Reporting for Mill

Quickstart

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.

File: 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/jacocoReportFull

Configure the Jacoco Version

You 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"

Collect multiple coverage data sets

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 tests

Download

Binary 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:

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"

License

This project is published under the Apache License, Version 2.0.

About

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.

Releases / Changelog

0.1.0 - 2025-11-13

  • Added support for Mill 1.x

0.0.4 - 2024-02-06

  • Better detect Mill test modules to exclude their files / classes from coverage reports. Requires at least Mill 0.11.7.

0.0.3 - 2023-06-24

  • Support for Mill 0.11

  • Dependency updates

0.0.2 - 2022-04-12

  • Support for Mill 0.10

0.0.1 - 2021-10-16

  • Initial Release

About

Coverage Reporting for Mill

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 3

  •  
  •  
  •