Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSOURCES-132] - Update Maven Archiver to 3.6.0 #5

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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