Class RequireFilesSize
- java.lang.Object
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
-
- org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
-
- org.apache.maven.enforcer.rules.files.AbstractRequireFiles
-
- org.apache.maven.enforcer.rules.files.RequireFilesSize
-
- All Implemented Interfaces:
EnforcerRuleBase
@Named("requireFilesSize") public final class RequireFilesSize extends AbstractRequireFiles
Rule to validate the main artifact is within certain size constraints.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
errorMsg
The error msg.private long
maxsize
the max size allowed.private static long
MAXSIZE
private long
minsize
the min size allowed.private org.apache.maven.project.MavenProject
project
private boolean
recursive
the mode for computing the size when the files are directories.
-
Constructor Summary
Constructors Constructor Description RequireFilesSize(org.apache.maven.project.MavenProject project)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
checkFile(java.io.File file)
Check one file.private long
computeLength(java.io.File file)
void
execute()
This is the interface into the rule.java.lang.String
getCacheId()
If the rule is to be cached during session scope, whole executing of Maven build, this id is used as part of the key.(package private) java.lang.String
getErrorMsg()
Gets the error msg.void
setMaxsize(long maxsize)
void
setMinsize(long minsize)
void
setRecursive(boolean recursive)
-
Methods inherited from class org.apache.maven.enforcer.rules.files.AbstractRequireFiles
getFiles, setAllowNulls, setFilesList, setSatisfyAny, toString
-
Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getLevel, getRuleName
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
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.
-
recursive
private boolean recursive
the mode for computing the size when the files are directories.
-
errorMsg
private java.lang.String errorMsg
The error msg.
-
project
private final org.apache.maven.project.MavenProject project
-
-
Method Detail
-
execute
public void execute() throws EnforcerRuleException
Description copied from class:AbstractEnforcerRule
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 and rule level if it should stop or just log the message as a warning.- Overrides:
execute
in classAbstractRequireFiles
- Throws:
EnforcerRuleException
- the enforcer rule exceptionEnforcerRuleError
- in order to brake a build immediately
-
getCacheId
public java.lang.String getCacheId()
Description copied from class:AbstractEnforcerRule
If the rule is to be cached during session scope, whole executing of Maven build, this id is used as part of the key.Rule of the same class and the same cache id will be executed once.
- Overrides:
getCacheId
in classAbstractRequireFiles
- Returns:
- id to be used by the Enforcer to determine uniqueness of cache results.
Return
null
disable cache of rule executing.
-
checkFile
boolean checkFile(java.io.File file)
Description copied from class:AbstractRequireFiles
Check one file.- Specified by:
checkFile
in classAbstractRequireFiles
- Parameters:
file
- the file- Returns:
true
if successful
-
computeLength
private long computeLength(java.io.File file)
-
getErrorMsg
java.lang.String getErrorMsg()
Description copied from class:AbstractRequireFiles
Gets the error msg.- Specified by:
getErrorMsg
in classAbstractRequireFiles
- Returns:
- the error msg
-
setMaxsize
public void setMaxsize(long maxsize)
-
setMinsize
public void setMinsize(long minsize)
-
setRecursive
public void setRecursive(boolean recursive)
-
-