Class RequireEncoding
java.lang.Object
org.apache.maven.plugins.enforcer.AbstractMojoHausEnforcerRule
org.apache.maven.plugins.enforcer.RequireEncoding
- All Implemented Interfaces:
org.apache.maven.enforcer.rule.api.EnforcerRule
,org.apache.maven.enforcer.rule.api.EnforcerRule2
Checks file encodings to see if they match the project.build.sourceEncoding If file encoding can not be determined it
is skipped.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Should the rule accept US-ASCII as an subset of UTF-8 and ISO-8859-1.private String
Validate files match this encoding.private String
Comma (or pipe) separated list of globs do exclude.private boolean
Should the rule fail after the first error or should the errors be aggregated.private String
Comma (or pipe) separated list of globs do include.private boolean
Enables SCM files exclusions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper helper) If your rule is cacheable, you must return a unique id when parameters or conditions change that would cause the result to be different.protected String
getEncoding
(String requiredEncoding, File file, org.apache.maven.plugin.logging.Log log) boolean
This tells the system if the results are cacheable at all.boolean
isResultValid
(org.apache.maven.enforcer.rule.api.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.boolean
void
setEncoding
(String encoding) void
setExcludes
(String excludes) void
setIncludes
(String includes) void
setUseDefaultExcludes
(boolean useDefaultExcludes) Methods inherited from class org.apache.maven.plugins.enforcer.AbstractMojoHausEnforcerRule
getLevel, setLevel
-
Field Details
-
encoding
Validate files match this encoding. If not specified then default to ${project.build.sourceEncoding}. -
includes
Comma (or pipe) separated list of globs do include. -
excludes
Comma (or pipe) separated list of globs do exclude. -
useDefaultExcludes
private boolean useDefaultExcludesEnables SCM files exclusions. Enabled by default. -
failFast
private boolean failFastShould the rule fail after the first error or should the errors be aggregated. -
acceptAsciiSubset
private boolean acceptAsciiSubsetShould the rule accept US-ASCII as an subset of UTF-8 and ISO-8859-1.
-
-
Constructor Details
-
RequireEncoding
public RequireEncoding()
-
-
Method Details
-
execute
public void execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper helper) throws org.apache.maven.enforcer.rule.api.EnforcerRuleException - Throws:
org.apache.maven.enforcer.rule.api.EnforcerRuleException
-
getEncoding
protected String getEncoding(String requiredEncoding, File file, org.apache.maven.plugin.logging.Log log) throws IOException - Throws:
IOException
-
getCacheId
If your rule is cacheable, you must return a unique id when parameters or conditions change that would cause the result to be different. Multiple cached results are stored based on their id. The easiest way to do this is to return a hash computed from the values of your parameters. If your rule is not cacheable, then the result here is not important, you may return anything. -
isCacheable
public boolean isCacheable()This tells the system if the results are cacheable at all. Keep in mind that during forked builds and other things, a given rule may be executed more than once for the same project. This means that even things that change from project to project may still be cacheable in certain instances. -
isResultValid
public boolean isResultValid(org.apache.maven.enforcer.rule.api.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. 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. -
getEncoding
-
setEncoding
-
getIncludes
-
setIncludes
-
getExcludes
-
setExcludes
-
isUseDefaultExcludes
public boolean isUseDefaultExcludes() -
setUseDefaultExcludes
public void setUseDefaultExcludes(boolean useDefaultExcludes)
-