Maven Enforcer Rule dependOnAllProjects
Maven Enforcer Plugin provides rules to control environmental and configurational constraints such as Maven version, JDK version, OS family, existence or non-existence of files and Maven profiles or properties. There are also many custom rules created by users or third parties.
Maven Enforcer Rule dependOnAllProjects, com.github.mikkoi:maven-enforcer-rule-depend-on-all-projects
is a user-created custom rule
to force any Maven project in a multimodule build to have a dependency on all other projects in the same build.
Use Cases
There is one general use case and one specific use case.
The rule ensures that when a multimodule Maven project is reconfigured by adding or removing subprojects,
all projects are listed as dependencies for that subproject in which
maven-enforcer-plugin
is executed. If used in a CI pipeline or in any similar manner,
this Maven Enforcer rule will keep the subproject up to date.
General Use Case
If there is something that needs to be done after everything else in the build is completed,
it can be placed into its own subproject with maven-enforcer-plugin
configured with this rule.
Jacoco Use Case
JaCoCo is a free Java code coverage library. When used in a multimodule project, after building and running tests for all subprojects that contain source code, the build must execute jacoco:report-aggregate.
This creates a structured (code coverage)[https://en.wikipedia.org/wiki/Code_coverage] report (HTML, XML, and CSV) from multiple projects within Maven reactor. The aggregated report is generated from all subprojects that the project depends on, and optionally from the subproject itself. The class and source files, as well as JaCoCo execution data files, will be collected from those projects.
In addition, execution data is collected from the project itself, if there is any. This also allows creating coverage reports when tests are in separate projects from the code under test, for example when integration tests live in a different module.
With Maven Enforcer Rule dependOnAllProjects, the subproject can ensure that all other subprojects are indeed listed as its dependencies, or that exceptions are configured properly.
Please refer to the Jacoco documentation for more details on how to configure
the jacoco-maven-plugin:report-aggregate
goal:
https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html