Skip to content

Commit

Permalink
MSITE-851 make output jars reproducible like m-source-p
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Nov 2, 2019
1 parent 9335776 commit 19be00a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Expand Up @@ -30,7 +30,7 @@ under the License.
</parent>

<artifactId>maven-site-plugin</artifactId>
<version>3.8.3-SNAPSHOT</version>
<version>3.9.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Apache Maven Site Plugin</name>
Expand Down Expand Up @@ -283,7 +283,7 @@ under the License.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>3.1.1</version>
<version>3.5.0</version>
</dependency>

<!-- dependencies to annotations -->
Expand All @@ -302,7 +302,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>3.4</version>
<version>4.2.1</version>
</dependency>

<dependency>
Expand All @@ -319,7 +319,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.24</version>
<version>3.3.0</version>
</dependency>

<dependency>
Expand Down
1 change: 1 addition & 0 deletions src/it/projects/site-jar/pom.xml
Expand Up @@ -34,6 +34,7 @@ under the License.
<properties>
<currentVersion>2.0.7</currentVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2019-11-02T17:48:12Z</project.build.outputTimestamp>
</properties>

<distributionManagement>
Expand Down
5 changes: 5 additions & 0 deletions src/it/projects/site-jar/verify.bsh
Expand Up @@ -50,6 +50,11 @@ try
while ( jarEntries.hasMoreElements() )
{
JarEntry entry = (JarEntry) jarEntries.nextElement();
if ( entry.getTime() != 1572713292000L )
{
System.out.println( "wrong entry time for " + entry.getName() + ": " + entry.getTime() );
return false;
}
if ( !entry.isDirectory() )
{
// Only compare files
Expand Down
Expand Up @@ -115,6 +115,16 @@ public class SiteJarMojo
@Parameter
private String[] archiveExcludes;

/**
* Timestamp for reproducible output archive entries, either formatted as ISO 8601
* <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
* <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>).
*
* @since 3.9.0
*/
@Parameter( defaultValue = "${project.build.outputTimestamp}" )
private String outputTimestamp;

/**
* @see org.apache.maven.plugin.Mojo#execute()
*/
Expand Down Expand Up @@ -179,14 +189,18 @@ private File createArchive( File siteDirectory, String jarFilename )
File siteJar = new File( jarOutputDirectory, jarFilename );

MavenArchiver archiver = new MavenArchiver();
archiver.setCreatedBy( "Maven Site Plugin", "org.apache.maven.plugins", "maven-site-plugin" );

archiver.setArchiver( this.jarArchiver );

archiver.setOutputFile( siteJar );

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

if ( !siteDirectory.isDirectory() )
{
getLog().warn( "JAR will be empty - no content was marked for inclusion !" );
getLog().warn( "JAR will be empty - no content was marked for inclusion!" );
}
else
{
Expand Down

0 comments on commit 19be00a

Please sign in to comment.