Quickstart
This quickstart shows how to configure the Maven Enforcer Plugin to use the maven-enforcer-rule-depend-on-all-projects rule in a multimodule build.
Prerequisites
- Maven 3.x or later.
- The rule artifact installed in your local repository or available from a remote repository.
Usage
- Add the Maven Enforcer Plugin to the project where you want to enforce the rule.
- Configure the rule inside the plugin configuration.
- Run the Enforcer Plugin during your build or call it manually.
Example configuration
Add the following snippet to the build section of the POM where you want the rule to run:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>enforce-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependOnAllProjects implementation="com.github.mikkoi:maven-enforcer-rule-depend-on-all-projects:1.0.0">
<includeRootProject>false</includeRootProject>
<errorIfUnknownProject>false</errorIfUnknownProject>
</dependOnAllProjects>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Run the rule
Execute the rule with:
mvn enforcer:enforce
Or run the full build to execute the plugin as part of the lifecycle:
mvn verify
Notes
- By default, all reactor projects are considered unless
includesorexcludesare specified. - Use the
includesandexcludesconfiguration parameters to control which projects are required as dependencies. - Set
includeRootProjecttotrueto include the root project in the dependency list. - Enable
errorIfUnknownProjectto fail the build when an include or exclude references a project not present in the current reactor.
