Class Reproducibility


  • public class Reproducibility
    extends java.lang.Object
    Helper class for allowing to produce so called "reproducible" output. I.e. multiple runs of the same steps should produce the same byte-by-byte result. This usually means that among other "randomness" timestamp should be avoided. This class provides a few useful bits to allow Apache POI to produce reproducible binary files. See https://reproducible-builds.org/ for more details.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reproducibility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isSourceDateEpoch()
      Check if the environment variable SOURCE_DATE_EPOCH is set.
      static void runWithSourceDateEpoch​(org.apache.commons.io.function.IORunnable r)
      Execute a runnable with SOURCE_DATE_EPOCH set.
      • Methods inherited from class java.lang.Object

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

      • Reproducibility

        public Reproducibility()
    • Method Detail

      • isSourceDateEpoch

        public static boolean isSourceDateEpoch()
        Check if the environment variable SOURCE_DATE_EPOCH is set.
        Returns:
        True if set, false otherwise
      • runWithSourceDateEpoch

        public static void runWithSourceDateEpoch​(org.apache.commons.io.function.IORunnable r)
                                           throws java.io.IOException
        Execute a runnable with SOURCE_DATE_EPOCH set. This is mostly only used in tests to check reproducibility of documents.
        Parameters:
        r - A runnable which executes the wanted steps with SOURCE_DATE_EPOCH defined
        Throws:
        java.io.IOException - if executing the runnable throws an IOException
        java.lang.RuntimeException - if executing the runnable throws a RuntimeException