Class RequireFilesSize
- java.lang.Object
-
- org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
-
- org.apache.maven.plugins.enforcer.AbstractRequireFiles
-
- org.apache.maven.plugins.enforcer.RequireFilesSize
-
- All Implemented Interfaces:
EnforcerRule,EnforcerRule2
public class RequireFilesSize extends AbstractRequireFiles
Rule to validate the main artifact is within certain size constraints.
-
-
Constructor Summary
Constructors Constructor Description RequireFilesSize()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleancheckFile(java.io.File file)Check one file.voidexecute(EnforcerRuleHelper helper)This is the interface into the rule.(package private) java.lang.StringgetErrorMsg()Gets the error msg.longgetMaxsize()longgetMinsize()booleanisCacheable()This method tells the enforcer if the rule results may be cached.booleanisResultValid(EnforcerRule cachedRule)If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to allow double checking of the results.voidsetMaxsize(long maxsize)voidsetMinsize(long minsize)-
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractRequireFiles
getCacheId, getFiles, isAllowNulls, setAllowNulls, setFiles
-
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
getLevel, getMessage, setLevel, setMessage
-
-
-
-
Field Detail
-
MAXSIZE
private static final long MAXSIZE
- See Also:
- Constant Field Values
-
maxsize
private long maxsize
the max size allowed.
-
minsize
private long minsize
the min size allowed.
-
errorMsg
private java.lang.String errorMsg
The error msg.
-
log
private org.apache.maven.plugin.logging.Log log
The log.
-
-
Method Detail
-
execute
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
Description copied from interface:EnforcerRuleThis 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.- Specified by:
executein interfaceEnforcerRule- Overrides:
executein classAbstractRequireFiles- 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:
EnforcerRuleException- the enforcer rule exception
-
isCacheable
public boolean isCacheable()
Description copied from interface:EnforcerRuleThis 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.- Specified by:
isCacheablein interfaceEnforcerRule- Overrides:
isCacheablein classAbstractRequireFiles- Returns:
trueif rule is cacheable
-
isResultValid
public boolean isResultValid(EnforcerRule cachedRule)
Description copied from interface:EnforcerRuleIf the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes the results of objects returned by the helper need to be queried. You may for example, store certain objects in your rule and then query them later.- Specified by:
isResultValidin interfaceEnforcerRule- Overrides:
isResultValidin classAbstractRequireFiles- 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:
trueif the stored results are valid for the same id.
-
checkFile
boolean checkFile(java.io.File file)
Description copied from class:AbstractRequireFilesCheck one file.- Specified by:
checkFilein classAbstractRequireFiles- Parameters:
file- the file- Returns:
trueif successful
-
getErrorMsg
java.lang.String getErrorMsg()
Description copied from class:AbstractRequireFilesGets the error msg.- Specified by:
getErrorMsgin classAbstractRequireFiles- Returns:
- the error msg
-
getMaxsize
public long getMaxsize()
-
setMaxsize
public void setMaxsize(long maxsize)
-
getMinsize
public long getMinsize()
-
setMinsize
public void setMinsize(long minsize)
-
-