Class RequireFilesSize

All Implemented Interfaces:
EnforcerRule, EnforcerRule2

public class RequireFilesSize extends AbstractRequireFiles
Rule to validate the main artifact is within certain size constraints.
  • Field Details

    • MAXSIZE

      private static final long MAXSIZE
      See Also:
    • maxsize

      private long maxsize
      the max size allowed.
    • minsize

      private long minsize
      the min size allowed.
    • errorMsg

      private String errorMsg
      The error msg.
    • log

      private org.apache.maven.plugin.logging.Log log
      The log.
  • Constructor Details

    • RequireFilesSize

      public RequireFilesSize()
  • Method Details

    • execute

      public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
      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 if it should stop or just log the message as a warning.
      Specified by:
      execute in interface EnforcerRule
      Overrides:
      execute in class AbstractRequireFiles
      Parameters:
      helper - The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • 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.
      Specified by:
      isCacheable in interface EnforcerRule
      Overrides:
      isCacheable in class AbstractRequireFiles
      Returns:
      true if rule is cacheable
    • isResultValid

      public boolean isResultValid(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.
      Specified by:
      isResultValid in interface EnforcerRule
      Overrides:
      isResultValid in class AbstractRequireFiles
      Parameters:
      cachedRule - the cached rule
      Returns:
      true if the stored results are valid for the same id.
    • checkFile

      boolean checkFile(File file)
      Check one file.
      Specified by:
      checkFile in class AbstractRequireFiles
      Parameters:
      file - the file
      Returns:
      true if successful
    • getErrorMsg

      String getErrorMsg()
      Gets the error msg.
      Specified by:
      getErrorMsg in class AbstractRequireFiles
      Returns:
      the error msg
    • getMaxsize

      public long getMaxsize()
    • setMaxsize

      public void setMaxsize(long maxsize)
    • getMinsize

      public long getMinsize()
    • setMinsize

      public void setMinsize(long minsize)