Jacoco Badge Gradle Plugin aims to analyze Jacoco Test Coverage Report and update the README file in your Java project with the badge link generated by Shields IO to reflect your code coverage on code change.
- Add this plugin in your
build.gradle
plugins {
id 'java'
id 'jacoco'
id 'com.github.dawnwords.jacoco.badge'
}- Put the badge link placeholder in your
README.md
# Your Project Name
some basic description
### code coverages



### some other introductionsNote that by default the README.md file should be placed in the project root directory together
with your build.gradle file.
- Execute generate jacoco badge task after jacoco report task
./gradlew jacocoTestReport generateJacocoBadgethen you'll see the coverage link in your README.md is automatically updated based on your jacoco
coverage report shown as following


There's a configuration point for this plugin: jacocoBadgeGenSetting in your build.gradle.
You can manually specify jacocoReportPath, readmePath and limit and their default value is shown
as following:
jacocoBadgeGenSetting {
jacocoReportPath "$buildDir/reports/jacoco/test/jacocoTestReport.xml"
readmePath "$projectDir/README.md"
// since v0.2.0, percentage limitation (0-100) for different type of coverage
limit = ['instruction': 0, 'branch': 0, 'line': 0, 'method': 0, 'class': 0]
}Jacoco gives us 6 coverage metrics in its test report, namely INSTRUCTION, BRANCH, LINE,
COMPLEXITY, METHOD and CLASS. Your badge link should be place within a new line and
the alt part should be one of the 6 values so that this plugin can detect them.