Skip to content

Commit

Permalink
[MSOURCES-132] - Update Maven Archiver to 3.6.0
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Solórzano <jorsol@gmail.com>
  • Loading branch information
jorsol authored and slawekjaranowski committed Jun 29, 2022
1 parent 7c9e681 commit e49c9df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ under the License.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
Expand Down
12 changes: 11 additions & 1 deletion src/it/reproducible/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* under the License.
*/

import java.nio.file.attribute.FileTime;
import java.time.Instant;
import org.apache.commons.compress.archivers.zip.*;

File deployDir = new File( basedir, 'target/repo/org/apache/maven/its/reproducible/1.0' )
Expand Down Expand Up @@ -63,13 +65,21 @@ long javaToDosTime( Date d )
d.getSeconds() >> 1;
}

// Normalize to UTC
long millis = Instant.parse( "2019-08-21T18:28:52Z" ).toEpochMilli();
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis( millis );
millis = millis - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get( Calendar.DST_OFFSET ) );
FileTime timestamp = FileTime.fromMillis( millis );

for ( ZipArchiveEntry zae : zipFile.getEntries() )
{
r.append( sprintf( "%d %4d (%3d) %8x %d %<tF %<tT %<tz %d %6o %s %s; %s\n", zae.getMethod(), zae.getSize(), zae.getCompressedSize(), zae.getCrc(), zae.getTime(), javaToDosTime( zae.getLastModifiedDate() ), zae.getUnixMode(), zae.getName(), ( zae.getComment() == null ) ? '-' : zae.getComment(), describeExtra( zae.getExtraFields() ) ) )
assert timestamp.equals( zae.getLastModifiedTime() );
}
zipFile.close();

String buf = r.toString()
println buf

assert buf.startsWith( "reproducible-1.0-sources.jar sha1 = 3a3687b063cfc164fbbccd1b9573b4232f540e8a" )
assert buf.startsWith( "reproducible-1.0-sources.jar sha1 = f159379802c1f0dc1083af21352286b09d364519" )
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,15 @@ protected MavenArchiver createArchiver()
archiver.setCreatedBy( "Maven Source Plugin", "org.apache.maven.plugins", "maven-source-plugin" );
archiver.setBuildJdkSpecDefaultEntry( false );


// configure for Reproducible Builds based on outputTimestamp value
archiver.configureReproducible( outputTimestamp );
archiver.configureReproducibleBuild( outputTimestamp );

if ( project.getBuild() != null )
{
List<Resource> resources = project.getBuild().getResources();

for ( Resource r : resources )
{

if ( r.getDirectory().endsWith( "maven-shared-archive-resources" ) )
{
addDirectory( archiver.getArchiver(), new File( r.getDirectory() ), getCombinedIncludes( null ),
Expand Down

0 comments on commit e49c9df

Please sign in to comment.