Brief examples on how to use the enforcer goals.

Generic Plugin configuration information

See the following links for information about including and configuring plugins in your project:

The enforcer:enforce mojo

This goal is meant to be bound to a lifecycle phase and configured in your pom.xml. The enforcers execute the configured rules to check for certain constraints. The available built-in rules are described here. Besides the rules to execute, these goals support three options:

  • skip - a quick way to skip checks via a profile or using -Denforcer.skip=true from the command line.
  • fail - if the goal should fail the build when a rule fails. The default is true. If false, the errors will be logged as warnings.
  • failFast - if the goal should stop checking after the first failure. The default is false.

Each rule to be executed should be added to the rules element along with the specific configuration for that rule.

As of version 1.4, you may add a level element to the rules. Valid values are WARN and ERROR. When level WARN is specified, the rule will only spit out a warning but will not fail the build.

Sample Plugin Configuration:

                  <!-- will only display a warning but does not fail the build. -->
                  <message>Please consider using the maven-invoker-plugin (!</message>

The enforcer:display-info mojo

This goal is used to determine the current information as detected by the standard rules:

   mvn enforcer:display-info
       Maven Version: 2.0.6
       JDK Version: 1.5.0_11 normalized as: 1.5.0-11
       OS Info: Arch: x86 Family: windows Name: windows xp Version: 5.1