https://github.com/sakata1222/jacoco-markdown-gradle-plugin
Gradle plugin to parse a jacoco report as a markdown
https://github.com/sakata1222/jacoco-markdown-gradle-plugin
coverage coverage-report gradle-plugin jacoco jacoco-report markdown
Last synced: 5 months ago
JSON representation
Gradle plugin to parse a jacoco report as a markdown
- Host: GitHub
- URL: https://github.com/sakata1222/jacoco-markdown-gradle-plugin
- Owner: sakata1222
- License: mit
- Created: 2020-12-31T02:39:50.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-08-02T15:09:16.000Z (11 months ago)
- Last Synced: 2025-08-02T16:13:38.127Z (11 months ago)
- Topics: coverage, coverage-report, gradle-plugin, jacoco, jacoco-report, markdown
- Language: Java
- Homepage:
- Size: 727 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jacoco-markdown-gradle-plugin
[](https://plugins.gradle.org/plugin/com.github.sakata1222.jacoco-markdown)
[](https://github.com/sakata1222/jacoco-markdown-gradle-plugin/actions?query=workflow%3A%22Java+CI+with+Gradle%22)
[](https://codecov.io/gh/sakata1222/jacoco-markdown-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=sakata1222_jacoco-markdown-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=sakata1222_jacoco-markdown-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=sakata1222_jacoco-markdown-gradle-plugin)
Gradle plugin to parse jacoco report as a markdown.
```shell
$ ./gradlew build
> Task :example:jacocoTestReportMarkdown
|Type | Missed/Total| Coverage|
|:--- | ---:| ---:|
|INSTRUCTION|~~8/18~~ 8/24| ~~55.56~~ 66.67%|
|BRANCH | ~~0/2~~ 0/4|(Not Changed)100.00%|
|LINE | ~~2/6~~ 2/8| ~~66.67~~ 75.00%|
Class list with less coverage (Worst 5)
|Class |Instructions(C0)|Branches(C1)|
|:--- | ---:| ---:|
|jp.gr.java_conf.spica.plugin.gradle.jacoco.example.App| 8/29(72.41%)|0/4(100.00%)|
```
The markdown is output by a file, so you can put the coverage on a Pull Request by using some CI
tools. For GitHub actions, you can use [github-script](https://github.com/actions/github-script) to
read the markdown and put it to the PR.
Gradle versions:
- 9.x
- 8.x
- 7.3 or later
Java versions:
- 8 or later
## Usage
### Apply plugin
This plugin depends on
the [jacoco plugin](https://docs.gradle.org/current/userguide/jacoco_plugin.html). So apply both the
jacoco plugin and this plugin.
```groovy
plugins {
id 'java'
id 'jacoco'
id "com.github.sakata1222.jacoco-markdown" version "X.Y.Z"
}
```
See also
[Gradle plugin portal](https://plugins.gradle.org/plugin/com.github.sakata1222.jacoco-markdown) to
check the latest version.
### Configuration
First, configure the jacoco plugin based on the [jacoco plugin guide](
https://docs.gradle.org/current/userguide/jacoco_plugin.html).
#### Default task
**A task to output coverage report as a markdown will be created by default, and dependencies are
also configured automatically.**
Configuration of the default task:
- Name is `Markdown` (i.e. jacocoTestReportMarkdown)
- The task depends on a default JacocoReport task
- A default JacocoReport task finalizedBy the task
- A markdown file will be output in `/jacocoSummary.md`
#### Define a new task
```groovy
task myJacocoMarkdown(type: jp.gr.java_conf.spica.plugin.gradle.jacoco.JacocoMarkdownTask) {
jacocoReportTask your_JacocoReport_task // auto configuration for the JacocoReportTask
}
```
#### Customize
For default task:
```groovy
jacocoMarkdown {
diffEnabled false // default true
stdout false // default true
classListEnabled false // default true
classListCondition {
limit = 2 // default is 5, 0 means no limit
excludes = [ // default is empty
"com.example.MyClass", // when a class name exact matches this value, the class will be exclude
"/com.example.exclude.package.*/" // regex can be used with "/regex/" style
]
branchCoverageLessThan = 90 // default is 0, 0 means no filter by coverage
}
}
```
For a specific task:
```groovy
myJacocoMarkdown {
jacocoXml file("path-to-jacoco-xml")
diffEnabled false
stdout false
classListEnabled false
classListCondition {
limit = 2
excludes = [
"com.example.MyClass",
"/com.example.exclude.package.*/"
]
branchCoverageLessThan = 90
}
previousJson file("path-to-a-base-json-to-show-the-coverage-changes")
targetTypes(["INSTRUCTION", "BRANCH", "LINE", "COMPLEXITY", "METHOD", "CLASS"])
outputJson file("path-to-output-json")
outputMd file("path-to-markdown")
}
```
#### Changelog
See [CHANGELOG.md](CHANGELOG.md)