{"id":29086039,"url":"https://github.com/surpsg/diff-coverage-maven-plugin","last_synced_at":"2025-09-03T13:18:42.705Z","repository":{"id":46276897,"uuid":"274510323","full_name":"SurpSG/diff-coverage-maven-plugin","owner":"SurpSG","description":"Maven plugin for computing code coverage on modified code","archived":false,"fork":false,"pushed_at":"2025-06-23T23:01:10.000Z","size":236,"stargazers_count":22,"open_issues_count":11,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T00:01:51.966Z","etag":null,"topics":["code-coverage","coverage","diff","diff-coverage","jacoco","java","kotlin","maven","maven-plugin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SurpSG.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-06-23T21:14:55.000Z","updated_at":"2025-03-01T21:57:51.000Z","dependencies_parsed_at":"2025-05-13T14:37:28.199Z","dependency_job_id":"04d11140-5966-40f5-b0f8-6a6bc47d4b53","html_url":"https://github.com/SurpSG/diff-coverage-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/SurpSG/diff-coverage-maven-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurpSG%2Fdiff-coverage-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurpSG%2Fdiff-coverage-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurpSG%2Fdiff-coverage-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurpSG%2Fdiff-coverage-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SurpSG","download_url":"https://codeload.github.com/SurpSG/diff-coverage-maven-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurpSG%2Fdiff-coverage-maven-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262352473,"owners_count":23297679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-coverage","coverage","diff","diff-coverage","jacoco","java","kotlin","maven","maven-plugin"],"created_at":"2025-06-28T00:01:15.784Z","updated_at":"2025-06-28T00:02:31.160Z","avatar_url":"https://github.com/SurpSG.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diff-coverage-maven-plugin\n\n[![Release](https://github.com/SurpSG/diff-coverage-maven-plugin/actions/workflows/release.yml/badge.svg)](https://github.com/SurpSG/diff-coverage-maven-plugin/actions/workflows/release.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.surpsg/diff-coverage-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.surpsg%22%20AND%20a:%22diff-coverage-maven-plugin%22)\n[![codecov](https://codecov.io/gh/SurpSG/diff-coverage-maven-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/SurpSG/diff-coverage-maven-plugin)\n\n`Diff coverage maven plugin` builds [JaCoCo](https://github.com/jacoco/jacoco) compatible code coverage report of new and modified code based on a provided [diff](https://en.wikipedia.org/wiki/Diff#Unified_format). \n\nThe plugin is able to check and fail a build if code coverage rules are not met.\n\n## How it works \n`Diff coverage` works in tandem with JaCoCo and requires JaCoCo to be applied to a project as well.\nThe plugin does the next steps:\n* analyzes coverage data('.exec' files generated by JaCoCo)\n* cuts off all code coverage data that wasn't modified\n* checks violation rules if any are set up\n* builds diff coverage HTML report. See [HTML report example](#Report-example)\n\n## Install plugin\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e \u003c!-- Make sure JaCoCo plugin is applied --\u003e\n            \u003cgroupId\u003eorg.jacoco\u003c/groupId\u003e\n            \u003cartifactId\u003ejacoco-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e0.8.10\u003c/version\u003e\n        \u003c/plugin\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eio.github.surpsg\u003c/groupId\u003e\n            \u003cartifactId\u003ediff-coverage-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e1.0.0\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003c!-- Required. diff content source. only one of file, URL or Git is allowed --\u003e\n                \u003cdiffSource\u003e\n                    \u003c!-- path to diff file --\u003e\n                    \u003cfile\u003epath/to/diffFile\u003c/file\u003e\n                    \n                    \u003c!-- branch, revision or tag --\u003e\n                    \u003cgit\u003eHEAD\u003c/git\u003e \u003c!-- compares current HEAD and all uncommited with this \u003cgit\u003e --\u003e\n                \n                    \u003c!-- URL to get diff content by. Used GET method --\u003e\n                    \u003curl\u003ehttp://url.com\u003c/url\u003e\n                \u003c/diffSource\u003e\n                \n                \u003c!-- Optional --\u003e\n                \u003cviolations\u003e \n                    \u003c!-- Default 'false'. Fail build if violation rules weren't met  --\u003e\n                    \u003cfailOnViolation\u003etrue\u003c/failOnViolation\u003e\n\n                    \u003c!-- Sets min coverage rule for: instructions, lines, branches --\u003e\n                    \u003cminCoverage\u003e0.7\u003c/minCoverage\u003e\n                    \n                    \u003c!-- Each rule could be configured separately --\u003e\n                    \u003c!-- Default '0.0'. If value is '0.0' then the rule is disabled --\u003e\n                    \u003cminLines\u003e0.1\u003c/minLines\u003e\n                    \u003cminBranches\u003e0.7\u003c/minBranches\u003e\n                    \u003cminInstructions\u003e1.0\u003c/minInstructions\u003e\n                \u003c/violations\u003e\n\n                \u003c!-- Optional. Exec files include pattern. By default 'build/jacoco.exec' file is used --\u003e\n                \u003cdataFileIncludes\u003e**/custom/exec/location/*.exec\u003c/dataFileIncludes\u003e\n                \n                \u003c!-- Optional. Exec files exclude pattern --\u003e\n                \u003cdataFileExcludes\u003e**/custom/**/exclude/*.exec\u003c/dataFileExcludes\u003e\n                \n                \u003c!-- Optional. Ant patterns by which we include classes for coverage report. --\u003e\n                \u003cincludes\u003e\n                    \u003cinclude\u003e**/package/**\u003c/include\u003e\n                    \u003cinclude\u003e**/ClassNamePrefix*\u003c/include\u003e\n                \u003c/includes\u003e\n                \u003c!-- Optional. Ant patterns by which we exclude classes from coverage report. --\u003e\n                \u003cexcludes\u003e\n                    \u003cexclude\u003e**/exclude/**/ClassName.class\u003c/exclude\u003e\n                \u003c/excludes\u003e\n                \u003c!-- If neither \u003cincludes\u003e nor \u003cexcludes\u003e are specified then we pass all classes for coverage report --\u003e\n                \n                \u003c!-- Enable/Disable reports --\u003e\n                \u003c!-- All reports are enabled by default --\u003e\n                \u003c!-- Available report type: html, xml, markdown, console --\u003e\n                \u003creports\u003e\n                    \u003creport\u003e\n                        \u003ctype\u003ehtml\u003c/type\u003e\n                        \u003cenabled\u003efalse\u003c/enabled\u003e\n                    \u003c/report\u003e\n                \u003c/reports\u003e\n                \n            \u003c/configuration\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003ediffCoverage\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n## Maven goal description \n`Diff Coverage Maven plugin` has a single goal `diffCoverage` that is bind to `verify` phase \n```shell script\n# run tests and build diff coverage report\nmvn clean verify\n\n# Invoke the goal explicitly.\n# It depends on `test` phase, make sure it's called when coverage data(*.exec files) already generated.  \nmvn clean test diff-coverage:diffCoverage\n```\n\n## Report example\nMaven output on failed violation rules:\n```\n[INFO] File src/main/kotlin/org/example/Hello.kt has 5 modified lines\n[INFO] New violation: Rule violated for bundle untitled: instructions covered ratio is 0.4, but expected minimum is 0.7\n[INFO] New violation: Rule violated for bundle untitled: lines covered ratio is 0.6, but expected minimum is 0.7\n[WARNING] Fail on violations: true. Found violations: 2.\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time:  9.919 s\n[INFO] Finished at: 2020-07-06T00:56:33+03:00\n[INFO] ------------------------------------------------------------------------\n[ERROR] Rule violated for bundle TestProj: instructions covered ratio is 0.4, but expected minimum is 0.7\n[ERROR] Rule violated for bundle TestProj: lines covered ratio is 0.6, but expected minimum is 0.7\n```\nThe plugin creates JaCoCo like HTML, XML and CSV reports in directory `target/site/diffCoverage/`.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/8483470/86543421-fba86100-bf26-11ea-9549-98f801d0f2b9.png\" width=500  alt=\"DiffCoverage HTML report\"/\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eJaCoCo HTML report\u003c/summary\u003e \n  \u003cimg src=\"https://user-images.githubusercontent.com/8483470/86543419-f3502600-bf26-11ea-873d-303c3a9d06dc.png\" width=500 alt=\"JaCoCo HTML report\"/\u003e        \n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurpsg%2Fdiff-coverage-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurpsg%2Fdiff-coverage-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurpsg%2Fdiff-coverage-maven-plugin/lists"}