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

public class RequireEncoding extends AbstractMojoHausEnforcerRule
Checks file encodings to see if they match the project.build.sourceEncoding If file encoding can not be determined it is skipped.
See Also:
  • Field Details

    • encoding

      private String encoding
      Validate files match this encoding. If not specified then default to ${project.build.sourceEncoding}.
    • includes

      private String includes
      Comma (or pipe) separated list of globs do include.
    • excludes

      private String excludes
      Comma (or pipe) separated list of globs do exclude.
    • useDefaultExcludes

      private boolean useDefaultExcludes
      Enables SCM files exclusions. Enabled by default.
    • failFast

      private boolean failFast
      Should the rule fail after the first error or should the errors be aggregated.
    • acceptAsciiSubset

      private boolean acceptAsciiSubset
      Should 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

      public String 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

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encoding)
    • getIncludes

      public String getIncludes()
    • setIncludes

      public void setIncludes(String includes)
    • getExcludes

      public String getExcludes()
    • setExcludes

      public void setExcludes(String excludes)
    • isUseDefaultExcludes

      public boolean isUseDefaultExcludes()
    • setUseDefaultExcludes

      public void setUseDefaultExcludes(boolean useDefaultExcludes)