-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MavenMultiModule
Support for Maven multi-module build is a long outstanding feature request for JaCoCo. This page tries to collect all information about this feature.
- Issue #18 Multi-report merging
- Issue #69 Multiply repot file merging with multimodule project reports aggregation
- Pull Request #97 Add aggregate-report that reports cross module code coverage for the maven plugin
- Pull Request #217 Allows the report mojo to reference binary/source files in other modules
The current JaCoCo Maven goals work on single modules only: Tests are executed within the module and contribute coverage only to code within the same module. Coverage reports are created for each module separately. There is no built-in support for cross-module coverage or combined reports for multiple modules.
- The JaCoCo Ant
report
task allows to specify arbitrary exec file, class file and source file locations. This task can be embedded with themaven-antrun-plugin
. - Use external tools for report generation like SonarQube.
There is a couple of use cases where code coverage needs to be determined across multiple modules:
- Creation of structured, browseable report for multiple modules.
- A report which shows the overall coverage figures (also check goals for overall coverage)
- Tests are located in a module separate from the code under test (e.g. Eclipse/Tycho). In this case the execution data is created within another module than the code under test.
- Integration tests might contribute code coverage to multiple modules.
More Aspects:
- Separate vs. combined reports for different test test levels (unit, it)
- Transitive coverage (e.g. test for A causes code coverage on B when A depends on B): this might be desirable or not
Using a aggregator module seems to be the natural solution as this directly reflects the project hierarchy. Unfortunately this approach comes with a number of drawbacks:
- Aggregator goals are executed before its submodules. But to create a combined coverage report the submodules needs to be built and tested first.
- Aggregator goals cannot be bound to a lifecycle phase, therefore must always be specified manually on the command line.
- There is very limited documentation for aggregators, some sources suggest that aggregators are deprecated and should not be used.
This approach requires a separate module to create the coverage report. The report is created for all modules a dependency is declared on. From those projects exec files as well as class and source files are collected.
- Maven Doc: Guide to Working with Multiple Modules
- Maven Doc: Mojo API Spec
- StackOverflow: How do I run a Maven Plugin on all modules?
TODO