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
FieldsModifier and TypeFieldDescriptionprotected static Hashtable<String, EnforcerRule> This is a static variable used to persist the cached results across plugin invocations.protected booleanUse this flag to disable rule result caching.protected org.apache.maven.plugin.MojoExecutionMojoExecution needed by the ExpressionEvaluatorprotected org.apache.maven.project.MavenProjectPOMprotected org.apache.maven.execution.MavenSessionThe MavenSessionprotected booleanFlag to easily skip all checksFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()voidsetCommandLineRules(List<String> rulesToExecute) Deprecated.voidsetFail(boolean theFail) voidsetFailFast(boolean theFailFast) voidsetFailIfNoRules(boolean thefailIfNoRules) voidsetRulesToExecute(List<String> rulesToExecute) List of strings that matches the EnforcerRules to execute.voidsetRulesToSkip(List<String> rulesToSkip) Set rule list to skip.protected booleanshouldExecute(EnforcerRule rule) This method determines if a rule should execute based on the cacheMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
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 mojoExecutionMojoExecution needed by the ExpressionEvaluator -
session
@Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession sessionThe MavenSession -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectPOM -
skip
Flag to easily skip all checks -
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
-
EnforceMojo
public EnforceMojo()
-
-
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 therulesproperty.- 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.Useenforcer.rulesproperty insteadList 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
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
shouldExecute
This method determines if a rule should execute based on the cache- Parameters:
rule- the rule to verify- Returns:
trueif rule should be executed, otherwisefalse
-
setRulesToSkip
Set rule list to skip.- Parameters:
rulesToSkip- a rule list
-
setFail
- Parameters:
theFail- the fail to set
-
setFailFast
- Parameters:
theFailFast- the failFast to set
-
setFailIfNoRules
- Parameters:
thefailIfNoRules- the failIfNoRules to set
-
enforcer.rulesproperty instead