Class 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:
    mikedon/encoding-enforcer, ericbn/encoding-enforcer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean acceptAsciiSubset
      Should the rule accept US-ASCII as an subset of UTF-8 and ISO-8859-1.
      private java.lang.String encoding
      Validate files match this encoding.
      private java.lang.String excludes
      Comma (or pipe) separated list of globs do exclude.
      private boolean failFast
      Should the rule fail after the first error or should the errors be aggregated.
      private java.lang.String includes
      Comma (or pipe) separated list of globs do include.
      private boolean useDefaultExcludes
      Enables SCM files exclusions.
    • Constructor Summary

      Constructors 
      Constructor Description
      RequireEncoding()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper helper)  
      java.lang.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.
      java.lang.String getEncoding()  
      protected java.lang.String getEncoding​(java.lang.String requiredEncoding, java.io.File file, org.apache.maven.plugin.logging.Log log)  
      java.lang.String getExcludes()  
      java.lang.String getIncludes()  
      boolean isCacheable()
      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 isUseDefaultExcludes()  
      void setEncoding​(java.lang.String encoding)  
      void setExcludes​(java.lang.String excludes)  
      void setIncludes​(java.lang.String includes)  
      void setUseDefaultExcludes​(boolean useDefaultExcludes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • encoding

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

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

        private java.lang.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 Detail

      • RequireEncoding

        public RequireEncoding()
    • Method Detail

      • 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 java.lang.String getEncoding​(java.lang.String requiredEncoding,
                                               java.io.File file,
                                               org.apache.maven.plugin.logging.Log log)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • getCacheId

        public java.lang.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 java.lang.String getEncoding()
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
      • getIncludes

        public java.lang.String getIncludes()
      • setIncludes

        public void setIncludes​(java.lang.String includes)
      • getExcludes

        public java.lang.String getExcludes()
      • setExcludes

        public void setExcludes​(java.lang.String excludes)
      • isUseDefaultExcludes

        public boolean isUseDefaultExcludes()
      • setUseDefaultExcludes

        public void setUseDefaultExcludes​(boolean useDefaultExcludes)