[ARCHETYPE-590] make archetype:jar reproductible
diff --git a/archetype-common/pom.xml b/archetype-common/pom.xml
index e4c714b..6976e9e 100644
--- a/archetype-common/pom.xml
+++ b/archetype-common/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>maven-archetype</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>archetype-common</artifactId>
@@ -75,7 +75,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-component-annotations</artifactId>
-      <version>1.5.5</version>
     </dependency>
     <dependency>
       <groupId>jdom</groupId>
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java b/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
index 57c58ce..1664ec8 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
@@ -85,7 +85,9 @@
      * @return The File to the generated jar
      * @throws org.apache.maven.artifact.DependencyResolutionRequiredException
      * @throws java.io.IOException
+     * @deprecated replaced by archetype plugin's JarMojo using maven-archiver component for Reproducible Builds
      */
+    @Deprecated
     File archiveArchetype( File archetypeDirectory, File outputDirectory, String finalName )
         throws DependencyResolutionRequiredException, IOException;
 
diff --git a/archetype-models/archetype-catalog/pom.xml b/archetype-models/archetype-catalog/pom.xml
index 1195dce..c166ae1 100644
--- a/archetype-models/archetype-catalog/pom.xml
+++ b/archetype-models/archetype-catalog/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>archetype-models</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>archetype-catalog</artifactId>
diff --git a/archetype-models/archetype-descriptor/pom.xml b/archetype-models/archetype-descriptor/pom.xml
index f5339d9..10ef915 100644
--- a/archetype-models/archetype-descriptor/pom.xml
+++ b/archetype-models/archetype-descriptor/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>archetype-models</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>archetype-descriptor</artifactId>
diff --git a/archetype-models/pom.xml b/archetype-models/pom.xml
index 7b3e6c7..e7d716f 100644
--- a/archetype-models/pom.xml
+++ b/archetype-models/pom.xml
@@ -1,23 +1,12 @@
 <?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.
--->
+<!-- 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">
 
@@ -26,7 +15,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>maven-archetype</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>archetype-models</artifactId>
diff --git a/archetype-packaging/pom.xml b/archetype-packaging/pom.xml
index dafd5c5..dc2f2ac 100644
--- a/archetype-packaging/pom.xml
+++ b/archetype-packaging/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>maven-archetype</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>archetype-packaging</artifactId>
diff --git a/maven-archetype-plugin/pom.xml b/maven-archetype-plugin/pom.xml
index 570e02c..048290a 100644
--- a/maven-archetype-plugin/pom.xml
+++ b/maven-archetype-plugin/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.maven.archetype</groupId>
     <artifactId>maven-archetype</artifactId>
-    <version>3.1.3-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <!--
@@ -67,6 +67,16 @@
       <groupId>org.apache.maven.archetype</groupId>
       <artifactId>archetype-common</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>3.5.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-archiver</artifactId>
+      <version>4.2.1</version>
+    </dependency>
     <!-- Required for the integration tests, dependency is only to define build order -->
     <dependency>
       <groupId>org.apache.maven.archetype</groupId>
diff --git a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
index c40e93a..c950f38 100644
--- a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
+++ b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
@@ -24,7 +24,9 @@
 import org.apache.maven.archetype.exception.UnknownArchetype;
 import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
 import org.apache.maven.archetype.metadata.RequiredProperty;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -33,9 +35,11 @@
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
 
 import java.io.File;
-import java.io.IOException;
+import java.util.Map;
 
 /**
  * Build a JAR from the current Archetype project.
@@ -71,6 +75,37 @@
     private MavenProject project;
 
     /**
+     * The {@link MavenSession}.
+     */
+    @Parameter( defaultValue = "${session}", readonly = true, required = true )
+    private MavenSession session;
+
+    /**
+     * The Jar archiver.
+     */
+    @Component
+    private Map<String, Archiver> archivers;
+
+    /**
+     * The archive configuration to use. See <a href="https://maven.apache.org/shared/maven-archiver/index.html">Maven
+     * Archiver Reference</a>.
+     *
+     * @since 3.2.0
+     */
+    @Parameter
+    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+    /**
+     * 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;
+
+    /**
      * The archetype manager component.
      */
     @Component
@@ -86,24 +121,33 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+        File jarFile = new File( outputDirectory, finalName + ".jar" );
+        getLog().info( "Building archetype jar: " + jarFile );
+
+        MavenArchiver archiver = new MavenArchiver();
+        archiver.setCreatedBy( "Maven Archetype Plugin", "org.apache.maven.plugins", "maven-archetype-plugin" );
+
+        archiver.setOutputFile( jarFile );
+
+        archiver.setArchiver( (JarArchiver) archivers.get( "jar" ) );
+
+        // configure for Reproducible Builds based on outputTimestamp value
+        archiver.configureReproducible( outputTimestamp );
+
         try
         {
-            getLog().info( "Building archetype jar: " + new File( outputDirectory, finalName ) );
+            archiver.getArchiver().addDirectory( archetypeDirectory );
 
-            File jarFile = manager.archiveArchetype( archetypeDirectory, outputDirectory, finalName );
-
-            checkArchetypeFile( jarFile );
-
-            project.getArtifact().setFile( jarFile );
+            archiver.createArchive( session, project, archive );
         }
-        catch ( DependencyResolutionRequiredException ex )
+        catch ( Exception e )
         {
-            throw new MojoExecutionException( ex.getMessage(), ex );
+            throw new MojoExecutionException( "Error assembling archetype jar " + jarFile, e );
         }
-        catch ( IOException ex )
-        {
-            throw new MojoExecutionException( ex.getMessage(), ex );
-        }
+
+        checkArchetypeFile( jarFile );
+
+        project.getArtifact().setFile( jarFile );
     }
 
     private void checkArchetypeFile( File jarFile )
diff --git a/pom.xml b/pom.xml
index d3a9af0..568297b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,7 +153,7 @@
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-utils</artifactId>
-        <version>3.2.0</version>
+        <version>3.3.0</version>
       </dependency>
       <dependency>
         <groupId>commons-io</groupId>