Skip to content

Commit

Permalink
replace sourceDateEpoch with a Date
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 12, 2019
1 parent 6964b62 commit 5913227
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
Expand Up @@ -1259,10 +1259,10 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( int sourceDateEpoch )
public void configureReproducible( Date outputTimestamp )
{
// 1. force last modified date
setLastModifiedDate( convertSourceDateEpochToDate( sourceDateEpoch ) );
setLastModifiedDate( convertOutputTimestamp( outputTimestamp ) );

// 2. sort filenames in each directory when scanning filesystem
setFilenameComparator( new Comparator<String>()
Expand All @@ -1286,8 +1286,8 @@ public int compare( String s1, String s2 )
setOverrideGroupName( "root" );
}

protected Date convertSourceDateEpochToDate( int sourceDateEpoch )
protected Date convertOutputTimestamp( Date outputTimestamp )
{
return new Date( sourceDateEpoch * 1000L );
return outputTimestamp;
}
}
7 changes: 2 additions & 5 deletions src/main/java/org/codehaus/plexus/archiver/Archiver.java
Expand Up @@ -468,11 +468,8 @@ ResourceIterator getResources()
* Builds</a>). This will require reproducible archive entries order, defined entries timestamp and reproducible
* entries Unix mode.
*
* @param sourceDateEpoch Value like SOURCE_DATE_EPOCH as
* <a href="https://reproducible-builds.org/specs/source-date-epoch/">defined in Reproducible Builds</a>:
* a UNIX timestamp, defined as the number of seconds, excluding leap seconds, since 01 Jan 1970 00:00:00
* UTC.
* @param outputTimestamp the date to use for archive entries last modified time
* @since 4.2.0
*/
void configureReproducible( int sourceDateEpoch );
void configureReproducible( Date outputTimestamp );
}
Expand Up @@ -400,9 +400,9 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( int sourceDateEpoch )
public void configureReproducible( Date outputTimestamp )
{
target.configureReproducible( sourceDateEpoch );
target.configureReproducible( outputTimestamp );
}

}
Expand Up @@ -415,7 +415,7 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( int sourceDateEpoch )
public void configureReproducible( Date outputTimestamp )
{

}
Expand Down
Expand Up @@ -470,7 +470,7 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( int sourceDateEpoch )
public void configureReproducible( Date outputTimestamp )
{
}
}
Expand Up @@ -836,12 +836,12 @@ protected String getArchiveType()
}

@Override
protected Date convertSourceDateEpochToDate( int sourceDateEpoch )
protected Date convertOutputTimestamp( Date outputTimestamp )
{
// timestamp of zip entries at zip storage level ignores timezone: managed in ZipEntry.setTime,
// that turns javaToDosTime: need to revert the operation here to get reproducible
// zip entry time
return new Date( dosToJavaTime( 1000L * sourceDateEpoch ) );
return new Date( dosToJavaTime( outputTimestamp.getTime() ) );
}

/**
Expand Down

0 comments on commit 5913227

Please sign in to comment.