Class Hasher

java.lang.Object
org.apache.maven.plugins.enforcer.Hasher

public class Hasher extends Object
Utility class to generate hashes/checksums for binary files. Typically used to generate a hashes for .class files to compare those files for equality.
  • Field Details

    • classFilePath

      private final String classFilePath
      the path to the .class file. Example: org/apache/maven/Stuff.class
  • Constructor Details

    • Hasher

      public Hasher(String classFilePath)
      Constructor.
      Parameters:
      classFilePath - The path to the .class file. This is the file we'll generate a hash for. Example: org/apache/maven/Stuff.class
  • Method Details

    • generateHash

      public String generateHash(org.apache.maven.artifact.Artifact artifact)
      Parameters:
      artifact - The artifact (example: jar file) which contains the classFilePath. We'll generate a hash for the class file inside this artifact.
      Returns:
      generate a hash/checksum for the .class file in the provided artifact.
    • hashForFileInDirectory

      private String hashForFileInDirectory(File artifactFile) throws IOException
      Throws:
      IOException
    • hashForFileInJar

      private String hashForFileInJar(File artifactFile) throws IOException
      Throws:
      IOException
    • closeAll

      private void closeAll(Closeable... closeables) throws IOException
      Throws:
      IOException