diff-coverage-maven-plugin
diff-coverage-maven-plugin copied to clipboard
Fix issue with submodules looking at other submodule class files
This fixes a problem with submodules where if it was previously built even using mvn clean it will look in other sub modules for their class files. Class files should be isolated to the module that the diff is being performed on. This will also skip running if a jacoco file is not found.
@SurpSG I've made some changes let me know what you think
@SurpSG saw the test failed added missing path files that were not added
Hi @rrourke
Thank you for this awesome work!
Still investigating your PR.
@SurpSG looks like it failed on itself, what do you want to do from here?
The plugin is applied to itself. It reported that coverage is not enough. But please, don't increase the coverage ritght now. Wait until I finish my investigation. Seems, Maven doesn't provide a clear way to solve this issue.
Suppose, we have a structure:
root
|__ module_1
|__module_2
|__pom.xml
What I expect:
- Jacoco maven plugin is aplied to submodules
- Diff Coverage is applied to the root only
- When we run
install
orverify
: ** tests are run in module_1(coverage is collected by jacoco) ** tests are run in module_2(coverage is collected by jacoco) ** Diff Coverage is run: *** collected .exec files from all projects *** collected classes from all projects *** Run diff coverage analyze. Finally, receive aggregated diff coverage report from entire project
Currently, it has a different behavior.
How it was implemented in jacoco maven plugin to receive the aggregated report? Recommendations from the jacoco team:
- create a separate subproject(
reporting-module
) that depends on all another projects - apply Jacoco aggregate to the
reporting-module
When we callinstall
: - all tests are run(coverage collected)
- at the end
reporting-module
is invoked with aggregation task
DiffCoverage maven plugin currently can work in the same way. See integration test: (multi-module-reports-generation-check)[https://github.com/SurpSG/diff-coverage-maven-plugin/tree/master/src/it/multi-module-reports-generation-check] But I don't like such approach. We have a separate module for reporting needs.
What we can do:
-
declare the DiffCoverageMojo.kt as aggregator(see about aggregator here) But the
verification
onroot
is invoked earlier than on subpojects, so we don't have coverage info at that moment. Somehow we should force invoking diff coverage that applied to theroot
after subproject's tests. -
Another solutiong - convert DiffCoverageMojo to report plugin. I have a draft code for this approach and seems it works as I expect. I need more time to investigate my approach and your solution as well