Class Reproducibility


  • public class Reproducibility
    extends 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 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 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:
        IOException - if executing the runnable throws an IOException
        RuntimeException - if executing the runnable throws a RuntimeException