Class RequireEncoding

  • All Implemented Interfaces:
    org.apache.maven.enforcer.rule.api.EnforcerRuleBase

    @Named("requireEncoding")
    public class RequireEncoding
    extends org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
    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/-15.
      private boolean acceptIso8859Subset
      Should the rule accept ISO-8859-1 as a subset of ISO-8859-15.
      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 static java.lang.String ISO_8859_15  
      private org.apache.maven.project.MavenProject project  
      private boolean useDefaultExcludes
      Enables SCM files exclusions.
    • Constructor Summary

      Constructors 
      Constructor Description
      RequireEncoding​(org.apache.maven.project.MavenProject project)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()  
      java.lang.String getEncoding()  
      protected java.lang.String getEncoding​(java.io.File file)  
      java.lang.String getExcludes()  
      java.lang.String getIncludes()  
      org.apache.maven.enforcer.rule.api.EnforcerLogger getLog()  
      boolean isUseDefaultExcludes()  
      void setEncoding​(java.lang.String encoding)  
      void setExcludes​(java.lang.String excludes)  
      void setIncludes​(java.lang.String includes)  
      void setLog​(org.apache.maven.enforcer.rule.api.EnforcerLogger arg0)  
      void setUseDefaultExcludes​(boolean useDefaultExcludes)  
      • Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule

        getCacheId, getLevel
      • 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/-15.
      • acceptIso8859Subset

        private boolean acceptIso8859Subset
        Should the rule accept ISO-8859-1 as a subset of ISO-8859-15.
      • project

        private final org.apache.maven.project.MavenProject project
    • Constructor Detail

      • RequireEncoding

        @Inject
        public RequireEncoding​(org.apache.maven.project.MavenProject project)
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.enforcer.rule.api.EnforcerRuleException
        Specified by:
        execute in class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
        Throws:
        org.apache.maven.enforcer.rule.api.EnforcerRuleException
      • getEncoding

        protected java.lang.String getEncoding​(java.io.File file)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • 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)
      • setLog

        public void setLog​(org.apache.maven.enforcer.rule.api.EnforcerLogger arg0)
        Specified by:
        setLog in interface org.apache.maven.enforcer.rule.api.EnforcerRuleBase
      • getLog

        public org.apache.maven.enforcer.rule.api.EnforcerLogger getLog()