You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2019/09/07 05:59:48 UTC

[maven-source-plugin] branch MSOURCES-120 updated: MSOURCES-120 document key configuration for Reproducible Builds

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MSOURCES-120
in repository https://gitbox.apache.org/repos/asf/maven-source-plugin.git


The following commit(s) were added to refs/heads/MSOURCES-120 by this push:
     new 852c203  MSOURCES-120 document key configuration for Reproducible Builds
852c203 is described below

commit 852c203c1f07e0e8bd84d22360141edd924ba472
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Sep 7 07:59:44 2019 +0200

    MSOURCES-120 document key configuration for Reproducible Builds
---
 .../apache/maven/plugins/source/AbstractSourceJarMojo.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
index 13bd352..da11f2d 100644
--- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
@@ -284,11 +284,16 @@ public abstract class AbstractSourceJarMojo
         
         if ( sourceDateEpoch != 0 )
         {
+            // configure for Reproducible Builds based on source date epoch value
             JarArchiver j = archiver.getArchiver();
+
+            // 1. force timestamp of zip entries (at zip storage level, that ignores timezone)
             Calendar cal = Calendar.getInstance();
             long zipTime =
                 1000L * sourceDateEpoch - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get( Calendar.DST_OFFSET ) );
             j.setLastModifiedDate( new Date( zipTime ) );
+
+            // 2. sort filenames in each directory when scanning filesystem
             j.setFilenameComparator( new Comparator<String>()
             {
                 @Override
@@ -297,8 +302,10 @@ public abstract class AbstractSourceJarMojo
                     return s1.compareTo( s2 );
                 }
             } );
-            j.setFileMode( Archiver.DEFAULT_FILE_MODE ); // notice: overrides execute bit on Unix
-                                                         // (that is already ignored on Windows)
+
+            // 3. ignore file/directory mode from filesystem, since they may vary based on local user umask
+            // notice: this overrides execute bit on Unix (that is already ignored on Windows)
+            j.setFileMode( Archiver.DEFAULT_FILE_MODE ); 
             j.setDirectoryMode( Archiver.DEFAULT_DIR_MODE );
         }