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:0.1.1">
<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
includes
orexcludes
are specified. - Use the
includes
andexcludes
configuration parameters to control which projects are required as dependencies. - Set
includeRootProject
totrue
to include the root project in the dependency list. - Enable
errorIfUnknownProject
to fail the build when an include or exclude references a project not present in the current reactor.