Class PedanticPluginConfigurationEnforcer

java.lang.Object
com.github.ferstl.maven.pomenforcers.AbstractPedanticEnforcer
com.github.ferstl.maven.pomenforcers.PedanticPluginConfigurationEnforcer
All Implemented Interfaces:
org.apache.maven.enforcer.rule.api.EnforcerRule, org.apache.maven.enforcer.rule.api.EnforcerRule2, org.apache.maven.enforcer.rule.api.EnforcerRuleBase

public class PedanticPluginConfigurationEnforcer extends AbstractPedanticEnforcer
Enforces that plugin versions, configurations and dependencies are defined in the <pluginManagement> section. Plugin <executions> can still be configured in the <plugins> section if this enforcer is active.
 ### Example
     <rules>
       <pluginConfiguration implementation="com.github.ferstl.maven.pomenforcers.PedanticPluginConfigurationEnforcer">
         <!-- all plugin versions have to be defined in plugin managment. -->
         <manageVersions>true</manageVersions>
         <!-- allow property references such as ${project.version} as versions outside plugin management -->
         <allowUnmanagedProjectVersions>true</allowUnmanagedProjectVersions>
         <!-- set the allowed property names for the allowUnmanagedProjectVersions option -->
         <allowedUnmanagedProjectVersionProperties>some-property.version,some-other.version</allowedUnmanagedProjectVersionProperties>
         <!-- plugin configuration (except execution configuration) has to be defined in plugin management. -->
         <manageConfigurations>true</manageConfigurations>
         <!-- plugin dependencies may be defined in the <plugins> section. -->
         <manageDependencies>false</manageDependencies>
       </pluginConfiguration>
     </rules>
 
Since:
1.0.0
Enforcer Rule ID:
PedanticEnforcerRule.PLUGIN_CONFIGURATION
  • Constructor Details

    • PedanticPluginConfigurationEnforcer

      public PedanticPluginConfigurationEnforcer()
  • Method Details

    • setManageVersions

      public void setManageVersions(boolean manageVersions)
      Enforces plugin versions to be defined in <pluginManagement>.
      Parameters:
      manageVersions - Enforces plugin versions to be defined in <pluginManagement>.
      Since:
      1.0.0
      Enforcer Configuration Parameter
      Default Value:
      true
    • setAllowUnmanagedProjectVersions

      public void setAllowUnmanagedProjectVersions(boolean allowUnmanagedProjectVersions)
      If set to true, ${project.version} may be used within the pluginManagement section.
      Parameters:
      allowUnmanagedProjectVersions - Allow project versions outside of the <pluginManagement> section.
      Since:
      2.2.0
      Enforcer Configuration Parameter
      Default Value:
      true
    • setAllowedUnmanagedProjectVersionProperties

      public void setAllowedUnmanagedProjectVersionProperties(String allowedUnmanagedProjectVersionProperties)
      Comma-separated list of Maven property variable names (without ${...}) which are allowed to be used as version references outside pluginManagement. Has no effect if allowUnmanagedProjectVersions is set to false.
      Parameters:
      allowedUnmanagedProjectVersionProperties - Set allowed property references for allowUnmanagedProjectVersions option.
      Since:
      2.2.0
      Enforcer Configuration Parameter
      Default Value:
      project.version,version
    • setManageConfigurations

      public void setManageConfigurations(boolean manageConfigurations)
      Enforces plugin configuration to be defined in <pluginManagement>.
      Parameters:
      manageConfigurations - Enforces plugin configuration to be defined in <pluginManagement>.
      Since:
      1.0.0
      Enforcer Configuration Parameter
      Default Value:
      true
    • setManageDependencies

      public void setManageDependencies(boolean manageDependencies)
      Enforces plugin dependencies to be defined in <pluginManagement>.
      Parameters:
      manageDependencies - Enforces plugin <dependencies> to be defined in <pluginManagement>.
      Since:
      1.0.0
      Enforcer Configuration Parameter
      Default Value:
      true
    • getDescription

      protected PedanticEnforcerRule getDescription()
      Specified by:
      getDescription in class AbstractPedanticEnforcer
    • accept

      protected void accept(PedanticEnforcerVisitor visitor)
      Specified by:
      accept in class AbstractPedanticEnforcer
    • doEnforce

      protected void doEnforce(ErrorReport report)
      Specified by:
      doEnforce in class AbstractPedanticEnforcer