Skip to content

Commit

Permalink
MSOURCES-120 moved reusable code to plexus-archiver PR #121
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Sep 8, 2019
1 parent 852c203 commit 3f5f97f
Showing 1 changed file with 1 addition and 25 deletions.
Expand Up @@ -23,9 +23,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import org.apache.maven.archiver.MavenArchiveConfiguration;
Expand Down Expand Up @@ -285,28 +282,7 @@ protected void packageSources( List<MavenProject> theProjects )
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
public int compare( String s1, String s2 )
{
return s1.compareTo( s2 );
}
} );

// 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 );
archiver.getArchiver().configureReproducible( sourceDateEpoch );
}

for ( MavenProject pItem : theProjects )
Expand Down

0 comments on commit 3f5f97f

Please sign in to comment.