This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-source-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 32f122a  MSOURCES-120 make output jar file binary Reproducible
32f122a is described below

commit 32f122aa7d2183fff36043c261d0a90bd9a4130a
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Tue Aug 20 23:05:12 2019 +0200

    MSOURCES-120 make output jar file binary Reproducible
---
 pom.xml                                            | 12 +++-
 src/it/reproducible/invoker.properties             | 18 +++++
 src/it/reproducible/pom.xml                        | 64 ++++++++++++++++++
 .../reproducible/src/main/resources/Uppercase.txt  | 17 +++++
 .../reproducible/src/main/resources/dir-A/A2.txt   | 17 +++++
 .../reproducible/src/main/resources/dir-A/A4.txt   | 17 +++++
 .../reproducible/src/main/resources/dir-A/a1.txt   | 34 ++++++++++
 .../reproducible/src/main/resources/dir-A/a3.txt   | 17 +++++
 src/it/reproducible/src/main/resources/dir-C/C.txt | 17 +++++
 .../src/main/resources/dir-b/B2/B2.txt             | 17 +++++
 .../src/main/resources/dir-b/B4/B4.txt             | 17 +++++
 src/it/reproducible/src/main/resources/dir-b/b.txt | 17 +++++
 .../src/main/resources/dir-b/b1/b1.txt             | 17 +++++
 .../src/main/resources/dir-b/b3/b3.txt             | 17 +++++
 src/it/reproducible/src/main/resources/dir-d/d.txt | 17 +++++
 .../reproducible/src/main/resources/executable.txt | 17 +++++
 .../reproducible/src/main/resources/lowercase.txt  | 17 +++++
 src/it/reproducible/verify.groovy                  | 77 ++++++++++++++++++++++
 .../plugins/source/AbstractSourceJarMojo.java      | 15 +++++
 19 files changed, 438 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index ebe3967..14851b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
   </parent>
 
   <artifactId>maven-source-plugin</artifactId>
-  <version>3.1.1-SNAPSHOT</version>
+  <version>3.2.0-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven Source Plugin</name>
@@ -110,12 +110,17 @@ under the License.
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-archiver</artifactId>
-      <version>3.4.0</version>
+      <version>3.5.0</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
-      <version>4.1.0</version>
+      <version>4.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.3.0</version>
     </dependency>
   
     <dependency>
@@ -161,6 +166,7 @@ under the License.
                 <goals>
                   <goal>install</goal>
                 </goals>
+                <addTestClassPath>true</addTestClassPath>
               </configuration>
             </plugin>
           </plugins>
diff --git a/src/it/reproducible/invoker.properties 
b/src/it/reproducible/invoker.properties
new file mode 100644
index 0000000..0b9ee6a
--- /dev/null
+++ b/src/it/reproducible/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals=source:jar deploy:deploy
diff --git a/src/it/reproducible/pom.xml b/src/it/reproducible/pom.xml
new file mode 100644
index 0000000..7a42e57
--- /dev/null
+++ b/src/it/reproducible/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>reproducible</artifactId>
+  <version>1.0</version>
+
+  <name>Test for reproducibility of jar</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    
<project.build.outputTimestamp>2019-08-21T18:28:52Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <!-- remove default entries since it contains "Created-By: Maven 
Source Plugin <current plugin version>"
+                   which varies over time in this IT -->
+              <addDefaultEntries>false</addDefaultEntries>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>2.8.2</version>
+        <configuration>
+          <!-- Deployments will be written to ${basedir}/target -->
+          
<altDeploymentRepository>mine::default::file://${basedir}/target/repo</altDeploymentRepository>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/reproducible/src/main/resources/Uppercase.txt 
b/src/it/reproducible/src/main/resources/Uppercase.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/Uppercase.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-A/A2.txt 
b/src/it/reproducible/src/main/resources/dir-A/A2.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-A/A2.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-A/A4.txt 
b/src/it/reproducible/src/main/resources/dir-A/A4.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-A/A4.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-A/a1.txt 
b/src/it/reproducible/src/main/resources/dir-A/a1.txt
new file mode 100644
index 0000000..ca0e172
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-A/a1.txt
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-A/a3.txt 
b/src/it/reproducible/src/main/resources/dir-A/a3.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-A/a3.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-C/C.txt 
b/src/it/reproducible/src/main/resources/dir-C/C.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-C/C.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-b/B2/B2.txt 
b/src/it/reproducible/src/main/resources/dir-b/B2/B2.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-b/B2/B2.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-b/B4/B4.txt 
b/src/it/reproducible/src/main/resources/dir-b/B4/B4.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-b/B4/B4.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-b/b.txt 
b/src/it/reproducible/src/main/resources/dir-b/b.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-b/b.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-b/b1/b1.txt 
b/src/it/reproducible/src/main/resources/dir-b/b1/b1.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-b/b1/b1.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-b/b3/b3.txt 
b/src/it/reproducible/src/main/resources/dir-b/b3/b3.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-b/b3/b3.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/dir-d/d.txt 
b/src/it/reproducible/src/main/resources/dir-d/d.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/dir-d/d.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/executable.txt 
b/src/it/reproducible/src/main/resources/executable.txt
new file mode 100755
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/executable.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/src/main/resources/lowercase.txt 
b/src/it/reproducible/src/main/resources/lowercase.txt
new file mode 100644
index 0000000..00ae6c0
--- /dev/null
+++ b/src/it/reproducible/src/main/resources/lowercase.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
diff --git a/src/it/reproducible/verify.groovy 
b/src/it/reproducible/verify.groovy
new file mode 100644
index 0000000..648d05a
--- /dev/null
+++ b/src/it/reproducible/verify.groovy
@@ -0,0 +1,77 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.compress.archivers.zip.*;
+
+File deployDir = new File( basedir, 
'target/repo/org/apache/maven/its/reproducible/1.0' )
+
+assert deployDir.exists()
+
+File sha1File = new File( deployDir, 'reproducible-1.0-sources.jar.sha1' )
+
+assert deployDir.exists()
+
+String sha1 = sha1File.text
+
+StringBuffer r = new StringBuffer()
+r.append( "reproducible-1.0-sources.jar sha1 = $sha1\n\n" )
+
+File jarFile = new File( deployDir, 'reproducible-1.0-sources.jar' )
+ZipFile zipFile = new ZipFile( jarFile );
+
+r.append( 'encoding: ' + zipFile.getEncoding()  + '\n' )
+r.append( 'timezone offset (minutes): ' + new Date().getTimezoneOffset() + 
'\n' )
+r.append( 'M size (cmp) crc      java time     date       time           zip 
time   mode   name -comment; extra\n' )
+
+String describeExtra( ZipExtraField[] extras )
+{
+  StringBuffer b = new StringBuffer()
+  b.append( extras.length )
+  for( ZipExtraField extra : extras )
+  {
+    b.append( sprintf( " [%s]%x", extra.getHeaderId().toString(), 
getLocalFileDataData() ) )
+  }
+  return b.toString()
+}
+
+long javaToDosTime( Date d )
+{
+    int year = d.getYear() + 1900;
+    if ( year < 1980 )
+    {
+        return ZipEntry.DOSTIME_BEFORE_1980;
+    }
+    return ( year - 1980 ) << 25 | ( d.getMonth() + 1 ) << 21 |
+           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
+           d.getSeconds() >> 1;
+}
+
+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() ) ) )
+}
+zipFile.close();
+
+String buf = r.toString()
+println buf
+
+String expectedSha1 = System.properties['os.name'].toLowerCase().contains( 
'windows' ) ? 'bb0a48a052defa69102e698aa18c60dea41a546a' : 
'246b4536d1a7df35b06cea54329077a35e6b07d8'
+
+assert buf.startsWith( "reproducible-1.0-sources.jar sha1 = $expectedSha1" )
diff --git 
a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
index 844c1fc..367e61f 100644
--- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
@@ -196,6 +196,16 @@ public abstract class AbstractSourceJarMojo
     @Parameter( defaultValue = "${session}", readonly = true, required = true )
     private MavenSession session;
 
+    /**
+     * 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.2.0
+     */
+    @Parameter( defaultValue = "${project.build.outputTimestamp}" )
+    private String outputTimestamp;
+
     // ----------------------------------------------------------------------
     // Public methods
     // ----------------------------------------------------------------------
@@ -270,6 +280,9 @@ public abstract class AbstractSourceJarMojo
         }
 
         MavenArchiver archiver = createArchiver();
+        
+        // configure for Reproducible Builds based on outputTimestamp value
+        archiver.configureReproducible( outputTimestamp );
 
         for ( MavenProject pItem : theProjects )
         {
@@ -408,6 +421,8 @@ public abstract class AbstractSourceJarMojo
     {
         MavenArchiver archiver = new MavenArchiver();
         archiver.setArchiver( jarArchiver );
+        archiver.setCreatedBy( "Maven Source Plugin", 
"org.apache.maven.plugins", "maven-source-plugin" );
+        archiver.setBuildJdkSpecDefaultEntry( false );
 
         if ( project.getBuild() != null )
         {

Reply via email to