Class RequireFileChecksum
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
org.apache.maven.enforcer.rules.checksum.RequireFileChecksum
- All Implemented Interfaces:
EnforcerRuleBase
- Direct Known Subclasses:
RequireTextFileChecksum
Rule to validate a binary file to match the specified checksum.
- Author:
- Edward Samson, Lyubomyr Shaydariv
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected String
calculateChecksum
(InputStream inputStream) void
execute()
This is the interface into the rule.getFile()
getLog()
Provide anEnforcerLogger
instance for RulegetType()
void
setChecksum
(String checksum) The expected checksum value.void
The file to check.void
setLog
(EnforcerLogger log) Used byEnforcerMojo
to inject logger instancevoid
setNonexistentFileMessage
(String nonexistentFileMessage) The friendly message to use when the file does not exist.void
The checksum algorithm to use.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
getCacheId, getLevel
-
Constructor Details
-
RequireFileChecksum
public RequireFileChecksum()
-
-
Method Details
-
execute
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.- Specified by:
execute
in classAbstractEnforcerRule
- Throws:
EnforcerRuleException
- the enforcer rule exception
-
setFile
The file to check.- Parameters:
file
- file
-
getFile
-
setChecksum
The expected checksum value.- Parameters:
checksum
- checksum
-
getChecksum
-
setType
The checksum algorithm to use. Possible values: "md5", "sha1", "sha256", "sha384", "sha512".- Parameters:
type
- algorithm
-
getType
-
setNonexistentFileMessage
The friendly message to use when the file does not exist.- Parameters:
nonexistentFileMessage
- message
-
getNonexistentFileMessage
-
calculateChecksum
- Throws:
EnforcerRuleException
-
calculateChecksum
protected String calculateChecksum(InputStream inputStream) throws IOException, EnforcerRuleException - Throws:
IOException
EnforcerRuleException
-
toString
-
setLog
Used byEnforcerMojo
to inject logger instance- Specified by:
setLog
in interfaceEnforcerRuleBase
- Parameters:
log
- anEnforcerLogger
instance
-
getLog
Provide anEnforcerLogger
instance for RuleNOTICE A logger is not available in constructors.
- Returns:
- an
EnforcerLogger
instance
-