diff-coverage-maven-plugin icon indicating copy to clipboard operation
diff-coverage-maven-plugin copied to clipboard

Fix issue with submodules looking at other submodule class files

Open rrourke opened this issue 2 years ago • 5 comments

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.

rrourke avatar Nov 08 '22 21:11 rrourke

@SurpSG I've made some changes let me know what you think

rrourke avatar Nov 16 '22 18:11 rrourke

@SurpSG saw the test failed added missing path files that were not added

rrourke avatar Nov 17 '22 18:11 rrourke

Hi @rrourke

Thank you for this awesome work!

Still investigating your PR.

SurpSG avatar Nov 21 '22 22:11 SurpSG

@SurpSG looks like it failed on itself, what do you want to do from here?

rrourke avatar Nov 22 '22 16:11 rrourke

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 or verify: ** 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 call install:
  • 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 on root 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 the root 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

SurpSG avatar Nov 22 '22 21:11 SurpSG