Skip to content

Commit 852c203

Browse files
committed
MSOURCES-120 document key configuration for Reproducible Builds
1 parent 67ca2da commit 852c203

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,16 @@ protected void packageSources( List<MavenProject> theProjects )
284284

285285
if ( sourceDateEpoch != 0 )
286286
{
287+
// configure for Reproducible Builds based on source date epoch value
287288
JarArchiver j = archiver.getArchiver();
289+
290+
// 1. force timestamp of zip entries (at zip storage level, that ignores timezone)
288291
Calendar cal = Calendar.getInstance();
289292
long zipTime =
290293
1000L * sourceDateEpoch - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get( Calendar.DST_OFFSET ) );
291294
j.setLastModifiedDate( new Date( zipTime ) );
295+
296+
// 2. sort filenames in each directory when scanning filesystem
292297
j.setFilenameComparator( new Comparator<String>()
293298
{
294299
@Override
@@ -297,8 +302,10 @@ public int compare( String s1, String s2 )
297302
return s1.compareTo( s2 );
298303
}
299304
} );
300-
j.setFileMode( Archiver.DEFAULT_FILE_MODE ); // notice: overrides execute bit on Unix
301-
// (that is already ignored on Windows)
305+
306+
// 3. ignore file/directory mode from filesystem, since they may vary based on local user umask
307+
// notice: this overrides execute bit on Unix (that is already ignored on Windows)
308+
j.setFileMode( Archiver.DEFAULT_FILE_MODE );
302309
j.setDirectoryMode( Archiver.DEFAULT_DIR_MODE );
303310
}
304311

0 commit comments

Comments
 (0)