moditect / moditect-gradle-plugin

A ModiTect plug-in for the Gradle build system
Apache License 2.0
11 stars 2 forks source link

Can not create reproducible archive #18

Open aalmiray opened 1 year ago

aalmiray commented 1 year ago

If the addMainModuleInfo task is invoked with reproducible archive settings (see docs) then entries for module-info.class won't be reproducible.

Sample project can be found at https://github.com/aalmiray/helloworld-jpms-reproducible

Building a non reproducible archive with ./gradle build yields

$ unzip -l build/libs/helloworld-jpms-reproducible-1.0.0.jar 
Archive:  build/libs/helloworld-jpms-reproducible-1.0.0.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  06-27-2023 19:31   META-INF/
       46  06-27-2023 19:31   META-INF/MANIFEST.MF
        0  06-27-2023 19:31   com/
        0  06-27-2023 19:31   com/acme/
      530  06-27-2023 19:31   com/acme/App.class
        0  06-27-2023 19:31   META-INF/versions/
        0  06-27-2023 19:31   META-INF/versions/11/
      183  06-27-2023 19:31   META-INF/versions/11/module-info.class
---------                     -------
      759                     8 files

Building a reproducible archive with ./gradlew build -PreproducibleBuild=true yields

$ unzip -l build/libs/helloworld-jpms-reproducible-1.0.0.jar 
Archive:  build/libs/helloworld-jpms-reproducible-1.0.0.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-01-1980 00:00   META-INF/
       46  02-01-1980 00:00   META-INF/MANIFEST.MF
        0  02-01-1980 00:00   com/
        0  02-01-1980 00:00   com/acme/
      530  02-01-1980 00:00   com/acme/App.class
        0  06-27-2023 19:31   META-INF/versions/
        0  06-27-2023 19:31   META-INF/versions/11/
      183  06-27-2023 19:31   META-INF/versions/11/module-info.class
---------                     -------
      759                     8 files

Timestamp for module-info.class and its containing directories do not honor reproducible settings.