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
Modifier and TypeFieldDescriptionprotected 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 ExpressionEvaluatorprotected org.apache.maven.project.MavenProject
POMprotected org.apache.maven.execution.MavenSession
The MavenSessionprotected boolean
Flag to easily skip all checksFields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
void
setCommandLineRules
(List<String> rulesToExecute) Deprecated.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
shouldExecute
(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 therules
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.Useenforcer.rules
property 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:
true
if 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.rules
property instead