Class EnforceMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.enforcer.EnforceMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="enforce", defaultPhase=VALIDATE, requiresDependencyCollection=TEST, threadSafe=true) public class EnforceMojo extends org.apache.maven.plugin.AbstractMojo
This goal executes the defined enforcer-rules once per module.
Author:
Brian Fox
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static Hashtable<String,EnforcerRule>
    This is a static variable used to persist the cached results across plugin invocations.
    protected boolean
    Use this flag to disable rule result caching.
    protected org.apache.maven.plugin.MojoExecution
    MojoExecution needed by the ExpressionEvaluator
    protected org.apache.maven.project.MavenProject
    POM
    protected org.apache.maven.execution.MavenSession
    The MavenSession
    protected boolean
    Flag to easily skip all checks

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    setCommandLineRules(List<String> rulesToExecute)
    Deprecated.
    Use enforcer.rules property instead
    void
    setFail(boolean theFail)
     
    void
    setFailFast(boolean theFailFast)
     
    void
    setFailIfNoRules(boolean thefailIfNoRules)
     
    void
    setRulesToExecute(List<String> rulesToExecute)
    List of strings that matches the EnforcerRules to execute.
    void
    setRulesToSkip(List<String> rulesToSkip)
    Set rule list to skip.
    protected boolean
    This method determines if a rule should execute based on the cache

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cache

      protected static Hashtable<String,EnforcerRule> cache
      This is a static variable used to persist the cached results across plugin invocations.
    • mojoExecution

      @Parameter(defaultValue="${mojoExecution}", readonly=true, required=true) protected org.apache.maven.plugin.MojoExecution mojoExecution
      MojoExecution needed by the ExpressionEvaluator
    • session

      @Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession session
      The MavenSession
    • project

      @Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject project
      POM
    • skip

      @Parameter(property="enforcer.skip", defaultValue="false") protected boolean skip
      Flag to easily skip all checks
    • ignoreCache

      @Parameter(property="enforcer.ignoreCache", defaultValue="false") protected boolean ignoreCache
      Use this flag to disable rule result caching. This will cause all rules to execute on each project even if the rule indicates it can safely be cached.
  • Constructor Details

  • Method Details

    • setRulesToExecute

      @Parameter(required=false, property="enforcer.rules") public void setRulesToExecute(List<String> rulesToExecute) throws org.apache.maven.plugin.MojoExecutionException
      List of strings that matches the EnforcerRules to execute. Replacement for the rules property.
      Parameters:
      rulesToExecute - a rules to execute
      Throws:
      org.apache.maven.plugin.MojoExecutionException - when values are incorrect
      Since:
      3.2.0
    • setCommandLineRules

      @Parameter(required=false, property="rules") @Deprecated public void setCommandLineRules(List<String> rulesToExecute) throws org.apache.maven.plugin.MojoExecutionException
      Deprecated.
      Use enforcer.rules property instead
      List of strings that matches the EnforcerRules to execute.
      Parameters:
      rulesToExecute - a rules to execute
      Throws:
      org.apache.maven.plugin.MojoExecutionException - when values are incorrect
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • shouldExecute

      protected boolean shouldExecute(EnforcerRule rule)
      This method determines if a rule should execute based on the cache
      Parameters:
      rule - the rule to verify
      Returns:
      true if rule should be executed, otherwise false
    • setRulesToSkip

      public void setRulesToSkip(List<String> rulesToSkip)
      Set rule list to skip.
      Parameters:
      rulesToSkip - a rule list
    • setFail

      public void setFail(boolean theFail)
      Parameters:
      theFail - the fail to set
    • setFailFast

      public void setFailFast(boolean theFailFast)
      Parameters:
      theFailFast - the failFast to set
    • setFailIfNoRules

      public void setFailIfNoRules(boolean thefailIfNoRules)
      Parameters:
      thefailIfNoRules - the failIfNoRules to set