org.apache.maven.enforcer.rule.api
Interface EnforcerRule


public interface EnforcerRule

Interface to be implemented by any rules executed by the enforcer.

Version:
$Id: EnforcerRule.java 675992 2008-07-11 15:42:48Z hboutemy $
Author:
Brian Fox

Method Summary
 void execute(EnforcerRuleHelper helper)
          This is the interface into the rule.
 java.lang.String getCacheId()
          If the rule is to be cached, this id is used as part of the key.
 boolean isCacheable()
          This method tells the enforcer if the rule results may be cached.
 boolean isResultValid(EnforcerRule cachedRule)
          Checks if cached result is valid.
 

Method Detail

execute

void execute(EnforcerRuleHelper helper)
             throws EnforcerRuleException
This is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag if it should stop or just log the message as a warning.

Parameters:
helper - The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.
Throws:
org.apache.maven.plugin.MojoExecutionException
EnforcerRuleException - the enforcer rule exception

isCacheable

boolean isCacheable()
This method tells the enforcer if the rule results may be cached. If the result is true, the results will be remembered for future executions in the same build (ie children). Subsequent iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be uncached further down the tree if needed.

Returns:
true if rule is cacheable

isResultValid

boolean isResultValid(EnforcerRule cachedRule)
Checks if cached result is valid.

Parameters:
cachedRule - the last cached instance of the rule. This is to be used by the rule to potentially determine if the results are still valid (ie if the configuration has been overridden)
Returns:
true if the stored results are valid for the same id.

getCacheId

java.lang.String getCacheId()
If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters that allow multiple results of the same rule to be cached.

Returns:
id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique within a given rule implementation as the full key will be [classname]-[id]


Copyright © 2007-2010 Apache Software Foundation. All Rights Reserved.