Class RequireFileChecksum
- 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.checksum.RequireFileChecksum
-
- All Implemented Interfaces:
EnforcerRuleBase
- Direct Known Subclasses:
RequireTextFileChecksum
@Named("requireFileChecksum") public class RequireFileChecksum extends AbstractStandardEnforcerRule
Rule to validate a binary file to match the specified checksum.- See Also:
RequireTextFileChecksum
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
checksum
private java.io.File
file
private java.lang.String
nonexistentFileMessage
private java.lang.String
type
-
Constructor Summary
Constructors Constructor Description RequireFileChecksum()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
calculateChecksum()
protected java.lang.String
calculateChecksum(java.io.InputStream inputStream)
void
execute()
This is the interface into the rule.java.lang.String
getChecksum()
java.io.File
getFile()
java.lang.String
getNonexistentFileMessage()
java.lang.String
getType()
void
setChecksum(java.lang.String checksum)
The expected checksum value.void
setFile(java.io.File file)
The file to check.void
setNonexistentFileMessage(java.lang.String nonexistentFileMessage)
The friendly message to use when the file does not exist.void
setType(java.lang.String type)
The checksum algorithm to use.java.lang.String
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
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
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.- Specified by:
execute
in classAbstractEnforcerRule
- Throws:
EnforcerRuleException
- the enforcer rule exceptionEnforcerRuleError
- in order to brake a build immediately
-
setFile
public void setFile(java.io.File file)
The file to check.- Parameters:
file
- file
-
getFile
public java.io.File getFile()
-
setChecksum
public void setChecksum(java.lang.String checksum)
The expected checksum value.- Parameters:
checksum
- checksum
-
getChecksum
public java.lang.String getChecksum()
-
setType
public void setType(java.lang.String type)
The checksum algorithm to use. Possible values: "md5", "sha1", "sha256", "sha384", "sha512".- Parameters:
type
- algorithm
-
getType
public java.lang.String getType()
-
setNonexistentFileMessage
public void setNonexistentFileMessage(java.lang.String nonexistentFileMessage)
The friendly message to use when the file does not exist.- Parameters:
nonexistentFileMessage
- message
-
getNonexistentFileMessage
public java.lang.String getNonexistentFileMessage()
-
calculateChecksum
protected java.lang.String calculateChecksum() throws EnforcerRuleException
- Throws:
EnforcerRuleException
-
calculateChecksum
protected java.lang.String calculateChecksum(java.io.InputStream inputStream) throws java.io.IOException, EnforcerRuleException
- Throws:
java.io.IOException
EnforcerRuleException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-