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

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


The following commit(s) were added to refs/heads/master by this push:
     new 07cc986  [MSHARED-1415] Switch to Maven 4 and the new api (#46)
07cc986 is described below

commit 07cc98665e8b859fd14c782eeb1921236a0ff9e8
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sat Jun 22 08:41:31 2024 +0200

    [MSHARED-1415] Switch to Maven 4 and the new api (#46)
---
 .github/workflows/maven-verify.yml                 |   6 +
 pom.xml                                            |  19 +-
 .../maven/archiver/ManifestConfiguration.java      |   2 -
 .../org/apache/maven/archiver/ManifestSection.java |   2 +-
 .../maven/archiver/MavenArchiveConfiguration.java  |  42 +-
 .../org/apache/maven/archiver/MavenArchiver.java   | 401 +++++-------
 .../maven/archiver/MavenArchiverException.java     |  37 ++
 .../apache/maven/archiver/PomPropertiesUtil.java   |  79 ++-
 .../archiver/MavenArchiveConfigurationTest.java    |   1 -
 .../apache/maven/archiver/MavenArchiverTest.java   | 676 ++++++++++-----------
 10 files changed, 595 insertions(+), 670 deletions(-)

diff --git a/.github/workflows/maven-verify.yml 
b/.github/workflows/maven-verify.yml
index 932827c..05b0414 100644
--- a/.github/workflows/maven-verify.yml
+++ b/.github/workflows/maven-verify.yml
@@ -25,3 +25,9 @@ jobs:
   build:
     name: Verify
     uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
+    with:
+      ff-maven: "4.0.0-beta-3"                     # Maven version for 
fail-fast-build
+      maven-matrix: '[ "4.0.0-beta-3" ]'
+      jdk-matrix: '[ "17", "21" ]'
+      ff-goal: verify
+      verify-goal: verify
diff --git a/pom.xml b/pom.xml
index 24a38c5..fb5f8fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
 
   <groupId>org.apache.maven</groupId>
   <artifactId>maven-archiver</artifactId>
-  <version>3.6.3-SNAPSHOT</version>
+  <version>4.0.0-SNAPSHOT</version>
 
   <name>Apache Maven Archiver</name>
   <description>Provides utility methods for creating JARs and other archive 
files from a Maven project.</description>
@@ -55,8 +55,8 @@
   </distributionManagement>
 
   <properties>
-    <mavenVersion>3.2.5</mavenVersion>
-    <javaVersion>8</javaVersion>
+    <mavenVersion>4.0.0-beta-3</mavenVersion>
+    <javaVersion>17</javaVersion>
     
<project.build.outputTimestamp>2024-03-24T22:30:56Z</project.build.outputTimestamp>
   </properties>
 
@@ -99,13 +99,14 @@
       Test dependencies
     -->
     <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-api</artifactId>
+      <groupId>org.apache.maven.plugin-testing</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>4.0.0-alpha-3-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-params</artifactId>
+      <artifactId>junit-jupiter</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -114,12 +115,6 @@
       <version>3.26.0</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <version>4.11.0</version>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
diff --git a/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java 
b/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
index 2640b8f..6b839b3 100644
--- a/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
+++ b/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
@@ -20,8 +20,6 @@ package org.apache.maven.archiver;
 
 /**
  * Capture common manifest configuration.
- *
- * @author <a href="mailto:[email protected]";>Brett Porter</a>
  */
 // TODO Is this general enough to be in Plexus Archiver?
 public class ManifestConfiguration {
diff --git a/src/main/java/org/apache/maven/archiver/ManifestSection.java 
b/src/main/java/org/apache/maven/archiver/ManifestSection.java
index 22dec5d..dd08e6c 100644
--- a/src/main/java/org/apache/maven/archiver/ManifestSection.java
+++ b/src/main/java/org/apache/maven/archiver/ManifestSection.java
@@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
- * <p>ManifestSection class.</p>
+ * ManifestSection class.
  */
 public class ManifestSection {
 
diff --git 
a/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java 
b/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
index 77bd7f8..86606a1 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
@@ -18,7 +18,7 @@
  */
 package org.apache.maven.archiver;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -35,15 +35,9 @@ public class MavenArchiveConfiguration {
 
     private boolean recompressAddedZips = true;
 
-    /**
-     * @deprecated See <a 
href="https://bugs.openjdk.org/browse/JDK-8305597";>JDK-8305597</a>
-     */
-    @Deprecated
-    private boolean index;
-
     private boolean addMavenDescriptor = true;
 
-    private File manifestFile;
+    private Path manifestFile;
 
     // TODO: Rename this attribute to manifestConfiguration;
     private ManifestConfiguration manifest;
@@ -60,7 +54,7 @@ public class MavenArchiveConfiguration {
     /**
      * @since 2.3
      */
-    private File pomPropertiesFile;
+    private Path pomPropertiesFile;
 
     /**
      * <p>isCompress.</p>
@@ -89,17 +83,6 @@ public class MavenArchiveConfiguration {
         this.recompressAddedZips = recompressAddedZips;
     }
 
-    /**
-     * <p>isIndex.</p>
-     *
-     * @return {@link #index}
-     * @deprecated See <a 
href="https://bugs.openjdk.org/browse/JDK-8305597";>JDK-8305597</a>
-     */
-    @Deprecated
-    public boolean isIndex() {
-        return index;
-    }
-
     /**
      * <p>isAddMavenDescriptor.</p>
      *
@@ -114,7 +97,7 @@ public class MavenArchiveConfiguration {
      *
      * @return {@link #manifestFile}
      */
-    public File getManifestFile() {
+    public Path getManifestFile() {
         return manifestFile;
     }
 
@@ -140,17 +123,6 @@ public class MavenArchiveConfiguration {
         this.compress = compress;
     }
 
-    /**
-     * <p>Setter for the field <code>index</code>.</p>
-     *
-     * @param index set index to true/false.
-     * @deprecated See <a 
href="https://bugs.openjdk.org/browse/JDK-8305597";>JDK-8305597</a>
-     */
-    @Deprecated
-    public void setIndex(boolean index) {
-        this.index = index;
-    }
-
     /**
      * <p>Setter for the field <code>addMavenDescriptor</code>.</p>
      *
@@ -165,7 +137,7 @@ public class MavenArchiveConfiguration {
      *
      * @param manifestFile The manifest file.
      */
-    public void setManifestFile(File manifestFile) {
+    public void setManifestFile(Path manifestFile) {
         this.manifestFile = manifestFile;
     }
 
@@ -316,7 +288,7 @@ public class MavenArchiveConfiguration {
      *
      * @return "pom.properties" location or null.
      */
-    public File getPomPropertiesFile() {
+    public Path getPomPropertiesFile() {
         return pomPropertiesFile;
     }
 
@@ -325,7 +297,7 @@ public class MavenArchiveConfiguration {
      *
      * @param pomPropertiesFile "pom.properties" location or null.
      */
-    public void setPomPropertiesFile(File pomPropertiesFile) {
+    public void setPomPropertiesFile(Path pomPropertiesFile) {
         this.pomPropertiesFile = pomPropertiesFile;
     }
 }
diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java 
b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index ad1e0db..11656fc 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -23,6 +23,9 @@ import javax.lang.model.SourceVersion;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.nio.file.attribute.FileTime;
 import java.time.Instant;
 import java.time.OffsetDateTime;
@@ -31,20 +34,20 @@ import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Properties;
-import java.util.Set;
 import java.util.jar.Attributes;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.MavenProject;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.api.Dependency;
+import org.apache.maven.api.PathScope;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.services.DependencyResolver;
+import org.apache.maven.api.services.DependencyResolverResult;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.jar.Manifest;
 import org.codehaus.plexus.archiver.jar.ManifestException;
@@ -62,18 +65,14 @@ import static 
org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_T
 import static 
org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_SIMPLE;
 
 /**
- * <p>MavenArchiver class.</p>
- *
- * @author <a href="[email protected]">Emmanuel Venisse</a>
- * @author kama
- * @version $Id: $Id
+ * MavenArchiver class.
  */
 public class MavenArchiver {
 
     private static final String CREATED_BY = "Maven Archiver";
 
     /**
-     * The simply layout.
+     * The simple layout.
      */
     public static final String SIMPLE_LAYOUT =
             
"${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}";
@@ -128,55 +127,58 @@ public class MavenArchiver {
      *
      * @param session the Maven Session
      * @param project the Maven Project
-     * @param config the MavenArchiveConfiguration
+     * @param config  the MavenArchiveConfiguration
      * @return the {@link org.codehaus.plexus.archiver.jar.Manifest}
-     * @throws org.codehaus.plexus.archiver.jar.ManifestException in case of a 
failure
-     * @throws org.apache.maven.artifact.DependencyResolutionRequiredException 
resolution failure
+     * @throws MavenArchiverException in case of a failure
      */
-    public Manifest getManifest(MavenSession session, MavenProject project, 
MavenArchiveConfiguration config)
-            throws ManifestException, DependencyResolutionRequiredException {
+    public Manifest getManifest(Session session, Project project, 
MavenArchiveConfiguration config)
+            throws MavenArchiverException {
         boolean hasManifestEntries = !config.isManifestEntriesEmpty();
         Map<String, String> entries = hasManifestEntries ? 
config.getManifestEntries() : Collections.emptyMap();
 
         Manifest manifest = getManifest(session, project, 
config.getManifest(), entries);
 
-        // any custom manifest entries in the archive configuration manifest?
-        if (hasManifestEntries) {
-
-            for (Map.Entry<String, String> entry : entries.entrySet()) {
-                String key = entry.getKey();
-                String value = entry.getValue();
-                Manifest.Attribute attr = 
manifest.getMainSection().getAttribute(key);
-                if (key.equals(Attributes.Name.CLASS_PATH.toString()) && attr 
!= null) {
-                    // Merge the user-supplied Class-Path value with the 
programmatically
-                    // created Class-Path. Note that the user-supplied value 
goes first
-                    // so that resources there will override any in the 
standard Class-Path.
-                    attr.setValue(value + " " + attr.getValue());
-                } else {
-                    addManifestAttribute(manifest, key, value);
+        try {
+            // any custom manifest entries in the archive configuration 
manifest?
+            if (hasManifestEntries) {
+
+                for (Map.Entry<String, String> entry : entries.entrySet()) {
+                    String key = entry.getKey();
+                    String value = entry.getValue();
+                    Manifest.Attribute attr = 
manifest.getMainSection().getAttribute(key);
+                    if (key.equals(Attributes.Name.CLASS_PATH.toString()) && 
attr != null) {
+                        // Merge the user-supplied Class-Path value with the 
programmatically
+                        // created Class-Path. Note that the user-supplied 
value goes first
+                        // so that resources there will override any in the 
standard Class-Path.
+                        attr.setValue(value + " " + attr.getValue());
+                    } else {
+                        addManifestAttribute(manifest, key, value);
+                    }
                 }
             }
-        }
 
-        // any custom manifest sections in the archive configuration manifest?
-        if (!config.isManifestSectionsEmpty()) {
-            for (ManifestSection section : config.getManifestSections()) {
-                Manifest.Section theSection = new Manifest.Section();
-                theSection.setName(section.getName());
+            // any custom manifest sections in the archive configuration 
manifest?
+            if (!config.isManifestSectionsEmpty()) {
+                for (ManifestSection section : config.getManifestSections()) {
+                    Manifest.Section theSection = new Manifest.Section();
+                    theSection.setName(section.getName());
 
-                if (!section.isManifestEntriesEmpty()) {
-                    Map<String, String> sectionEntries = 
section.getManifestEntries();
+                    if (!section.isManifestEntriesEmpty()) {
+                        Map<String, String> sectionEntries = 
section.getManifestEntries();
 
-                    for (Map.Entry<String, String> entry : 
sectionEntries.entrySet()) {
-                        String key = entry.getKey();
-                        String value = entry.getValue();
-                        Manifest.Attribute attr = new Manifest.Attribute(key, 
value);
-                        theSection.addConfiguredAttribute(attr);
+                        for (Map.Entry<String, String> entry : 
sectionEntries.entrySet()) {
+                            String key = entry.getKey();
+                            String value = entry.getValue();
+                            Manifest.Attribute attr = new 
Manifest.Attribute(key, value);
+                            theSection.addConfiguredAttribute(attr);
+                        }
                     }
-                }
 
-                manifest.addConfiguredSection(theSection);
+                    manifest.addConfiguredSection(theSection);
+                }
             }
+        } catch (ManifestException e) {
+            throw new MavenArchiverException("Unable to create manifest", e);
         }
 
         return manifest;
@@ -185,32 +187,19 @@ public class MavenArchiver {
     /**
      * Return a pre-configured manifest.
      *
-     * @param project {@link org.apache.maven.project.MavenProject}
-     * @param config {@link org.apache.maven.archiver.ManifestConfiguration}
+     * @param project {@link org.apache.maven.api.Project}
+     * @param config  {@link org.apache.maven.archiver.ManifestConfiguration}
      * @return {@link org.codehaus.plexus.archiver.jar.Manifest}
-     * @throws org.codehaus.plexus.archiver.jar.ManifestException Manifest 
exception.
-     * @throws org.apache.maven.artifact.DependencyResolutionRequiredException 
Dependency resolution exception.
+     * @throws MavenArchiverException exception.
      */
     // TODO Add user attributes list and user groups list
-    public Manifest getManifest(MavenProject project, ManifestConfiguration 
config)
-            throws ManifestException, DependencyResolutionRequiredException {
+    public Manifest getManifest(Project project, ManifestConfiguration config) 
throws MavenArchiverException {
         return getManifest(null, project, config, Collections.emptyMap());
     }
 
-    /**
-     * <p>getManifest.</p>
-     *
-     * @param mavenSession {@link org.apache.maven.execution.MavenSession}
-     * @param project      {@link org.apache.maven.project.MavenProject}
-     * @param config       {@link 
org.apache.maven.archiver.ManifestConfiguration}
-     * @return {@link org.codehaus.plexus.archiver.jar.Manifest}
-     * @throws org.codehaus.plexus.archiver.jar.ManifestException              
the manifest exception
-     * @throws org.apache.maven.artifact.DependencyResolutionRequiredException 
the dependency resolution required
-     *                                                                         
exception
-     */
-    public Manifest getManifest(MavenSession mavenSession, MavenProject 
project, ManifestConfiguration config)
-            throws ManifestException, DependencyResolutionRequiredException {
-        return getManifest(mavenSession, project, config, 
Collections.emptyMap());
+    public Manifest getManifest(Session session, Project project, 
ManifestConfiguration config)
+            throws MavenArchiverException {
+        return getManifest(session, project, config, Collections.emptyMap());
     }
 
     private void addManifestAttribute(Manifest manifest, Map<String, String> 
map, String key, String value)
@@ -236,20 +225,27 @@ public class MavenArchiver {
     /**
      * <p>getManifest.</p>
      *
-     * @param session {@link org.apache.maven.execution.MavenSession}
-     * @param project {@link org.apache.maven.project.MavenProject}
+     * @param session {@link org.apache.maven.api.Session}
+     * @param project {@link org.apache.maven.api.Project}
      * @param config  {@link org.apache.maven.archiver.ManifestConfiguration}
      * @param entries The entries.
      * @return {@link org.codehaus.plexus.archiver.jar.Manifest}
-     * @throws org.codehaus.plexus.archiver.jar.ManifestException              
the manifest exception
-     * @throws org.apache.maven.artifact.DependencyResolutionRequiredException 
the dependency resolution required
-     *                                                                         
exception
+     * @throws MavenArchiverException exception
      */
     protected Manifest getManifest(
-            MavenSession session, MavenProject project, ManifestConfiguration 
config, Map<String, String> entries)
-            throws ManifestException, DependencyResolutionRequiredException {
-        // TODO: Should we replace "map" with a copy? Note, that we modify it!
+            Session session, Project project, ManifestConfiguration config, 
Map<String, String> entries)
+            throws MavenArchiverException {
+        try {
+            return doGetManifest(session, project, config, entries);
+        } catch (ManifestException e) {
+            throw new MavenArchiverException("Unable to create manifest", e);
+        }
+    }
 
+    protected Manifest doGetManifest(
+            Session session, Project project, ManifestConfiguration config, 
Map<String, String> entries)
+            throws ManifestException {
+        // TODO: Should we replace "map" with a copy? Note, that we modify it!
         Manifest m = new Manifest();
 
         if (config.isAddDefaultEntries()) {
@@ -260,34 +256,39 @@ public class MavenArchiver {
             handleBuildEnvironmentEntries(session, m, entries);
         }
 
+        DependencyResolverResult result;
+        if (config.isAddClasspath() || config.isAddExtensions()) {
+            result = 
session.getService(DependencyResolver.class).resolve(session, project, 
PathScope.MAIN_RUNTIME);
+        } else {
+            result = null;
+        }
+
         if (config.isAddClasspath()) {
             StringBuilder classpath = new StringBuilder();
 
-            List<String> artifacts = project.getRuntimeClasspathElements();
             String classpathPrefix = config.getClasspathPrefix();
             String layoutType = config.getClasspathLayoutType();
             String layout = config.getCustomClasspathLayout();
 
             Interpolator interpolator = new StringSearchInterpolator();
 
-            for (String artifactFile : artifacts) {
-                File f = new File(artifactFile);
-                if (f.getAbsoluteFile().isFile()) {
-                    Artifact artifact = 
findArtifactWithFile(project.getArtifacts(), f);
-
-                    if (classpath.length() > 0) {
+            for (Map.Entry<Dependency, Path> entry : 
result.getDependencies().entrySet()) {
+                Path artifactFile = entry.getValue();
+                Dependency dependency = entry.getKey();
+                if (Files.isRegularFile(artifactFile.toAbsolutePath())) {
+                    if (!classpath.isEmpty()) {
                         classpath.append(" ");
                     }
                     classpath.append(classpathPrefix);
 
                     // NOTE: If the artifact or layout type (from config) is 
null, give up and use the file name by
                     // itself.
-                    if (artifact == null || layoutType == null) {
-                        classpath.append(f.getName());
+                    if (dependency == null || layoutType == null) {
+                        
classpath.append(artifactFile.getFileName().toString());
                     } else {
                         List<ValueSource> valueSources = new ArrayList<>();
 
-                        handleExtraExpression(artifact, valueSources);
+                        handleExtraExpression(dependency, valueSources);
 
                         for (ValueSource vs : valueSources) {
                             interpolator.addValueSource(vs);
@@ -347,7 +348,7 @@ public class MavenArchiver {
                 }
             }
 
-            if (classpath.length() > 0) {
+            if (!classpath.isEmpty()) {
                 // Class-Path is special and should be added to manifest even 
if
                 // it is specified in the manifestEntries section
                 addManifestAttribute(m, "Class-Path", classpath.toString());
@@ -363,33 +364,34 @@ public class MavenArchiver {
         }
 
         String mainClass = config.getMainClass();
-        if (mainClass != null && !"".equals(mainClass)) {
+        if (mainClass != null && !mainClass.isEmpty()) {
             addManifestAttribute(m, entries, "Main-Class", mainClass);
         }
 
+        /*
         if (config.isAddExtensions()) {
-            handleExtensions(project, entries, m);
+            handleExtensions(result.getDependencies(), entries, m);
         }
+        */
 
         addCustomEntries(m, entries, config);
 
         return m;
     }
 
-    private void handleExtraExpression(Artifact artifact, List<ValueSource> 
valueSources) {
-        valueSources.add(new 
PrefixedObjectValueSource(ARTIFACT_EXPRESSION_PREFIXES, artifact, true));
-        valueSources.add(
-                new PrefixedObjectValueSource(ARTIFACT_EXPRESSION_PREFIXES, 
artifact.getArtifactHandler(), true));
+    private void handleExtraExpression(Dependency dependency, 
List<ValueSource> valueSources) {
+        valueSources.add(new 
PrefixedObjectValueSource(ARTIFACT_EXPRESSION_PREFIXES, dependency, true));
+        valueSources.add(new 
PrefixedObjectValueSource(ARTIFACT_EXPRESSION_PREFIXES, dependency.getType(), 
true));
 
         Properties extraExpressions = new Properties();
         // FIXME: This query method SHOULD NOT affect the internal
         // state of the artifact version, but it does.
-        if (!artifact.isSnapshot()) {
-            extraExpressions.setProperty("baseVersion", artifact.getVersion());
+        if (!dependency.isSnapshot()) {
+            extraExpressions.setProperty("baseVersion", 
dependency.getVersion().toString());
         }
 
-        extraExpressions.setProperty("groupIdPath", 
artifact.getGroupId().replace('.', '/'));
-        String classifier = artifact.getClassifier();
+        extraExpressions.setProperty("groupIdPath", 
dependency.getGroupId().replace('.', '/'));
+        String classifier = dependency.getClassifier();
         if (classifier != null && !classifier.isEmpty()) {
             extraExpressions.setProperty("dashClassifier", "-" + classifier);
             extraExpressions.setProperty("dashClassifier?", "-" + classifier);
@@ -400,79 +402,50 @@ public class MavenArchiver {
         valueSources.add(new 
PrefixedPropertiesValueSource(ARTIFACT_EXPRESSION_PREFIXES, extraExpressions, 
true));
     }
 
-    private void handleExtensions(MavenProject project, Map<String, String> 
entries, Manifest m)
+    private void handleImplementationEntries(Project project, Map<String, 
String> entries, Manifest m)
             throws ManifestException {
-        // TODO: this is only for applets - should we distinguish them as a 
packaging?
-        StringBuilder extensionsList = new StringBuilder();
-        Set<Artifact> artifacts = project.getArtifacts();
-
-        for (Artifact artifact : artifacts) {
-            if (!Artifact.SCOPE_TEST.equals(artifact.getScope())) {
-                if ("jar".equals(artifact.getType())) {
-                    if (extensionsList.length() > 0) {
-                        extensionsList.append(" ");
-                    }
-                    extensionsList.append(artifact.getArtifactId());
-                }
-            }
-        }
-
-        if (extensionsList.length() > 0) {
-            addManifestAttribute(m, entries, "Extension-List", 
extensionsList.toString());
-        }
-
-        for (Artifact artifact : artifacts) {
-            // TODO: the correct solution here would be to have an extension 
type, and to read
-            // the real extension values either from the artifact's manifest 
or some part of the POM
-            if ("jar".equals(artifact.getType())) {
-                String artifactId = artifact.getArtifactId().replace('.', '_');
-                String ename = artifactId + "-Extension-Name";
-                addManifestAttribute(m, entries, ename, 
artifact.getArtifactId());
-                String iname = artifactId + "-Implementation-Version";
-                addManifestAttribute(m, entries, iname, artifact.getVersion());
-
-                if (artifact.getRepository() != null) {
-                    iname = artifactId + "-Implementation-URL";
-                    String url = artifact.getRepository().getUrl() + "/" + 
artifact;
-                    addManifestAttribute(m, entries, iname, url);
-                }
-            }
-        }
-    }
-
-    private void handleImplementationEntries(MavenProject project, Map<String, 
String> entries, Manifest m)
-            throws ManifestException {
-        addManifestAttribute(m, entries, "Implementation-Title", 
project.getName());
+        addManifestAttribute(
+                m, entries, "Implementation-Title", 
project.getModel().getName());
         addManifestAttribute(m, entries, "Implementation-Version", 
project.getVersion());
 
-        if (project.getOrganization() != null) {
+        if (project.getModel().getOrganization() != null) {
             addManifestAttribute(
                     m,
                     entries,
                     "Implementation-Vendor",
-                    project.getOrganization().getName());
+                    project.getModel().getOrganization().getName());
         }
     }
 
-    private void handleSpecificationEntries(MavenProject project, Map<String, 
String> entries, Manifest m)
+    private void handleSpecificationEntries(Project project, Map<String, 
String> entries, Manifest m)
             throws ManifestException {
-        addManifestAttribute(m, entries, "Specification-Title", 
project.getName());
+        addManifestAttribute(
+                m, entries, "Specification-Title", 
project.getModel().getName());
 
+        String version = project.getPomArtifact().getVersion().toString();
+        Matcher matcher = 
Pattern.compile("([0-9]+\\.[0-9]+)(.*?)").matcher(version);
+        if (matcher.matches()) {
+            String specVersion = matcher.group(1);
+            addManifestAttribute(m, entries, "Specification-Version", 
specVersion);
+        }
+        /*
+        TODO: v4: overconstrained
         try {
-            ArtifactVersion version = 
project.getArtifact().getSelectedVersion();
+            Version version = project.getArtifact().getVersion();
             String specVersion = String.format("%s.%s", 
version.getMajorVersion(), version.getMinorVersion());
             addManifestAttribute(m, entries, "Specification-Version", 
specVersion);
         } catch (OverConstrainedVersionException e) {
             throw new ManifestException("Failed to get selected artifact 
version to calculate"
-                    + " the specification version: " + e.getMessage());
+                + " the specification version: " + e.getMessage());
         }
+        */
 
-        if (project.getOrganization() != null) {
+        if (project.getModel().getOrganization() != null) {
             addManifestAttribute(
                     m,
                     entries,
                     "Specification-Vendor",
-                    project.getOrganization().getName());
+                    project.getModel().getOrganization().getName());
         }
     }
 
@@ -518,21 +491,24 @@ public class MavenArchiver {
     /**
      * <p>createArchive.</p>
      *
-     * @param session {@link org.apache.maven.execution.MavenSession}
-     * @param project {@link org.apache.maven.project.MavenProject}
+     * @param session              {@link org.apache.maven.api.Session}
+     * @param project              {@link org.apache.maven.api.Project}
      * @param archiveConfiguration {@link 
org.apache.maven.archiver.MavenArchiveConfiguration}
-     * @throws org.codehaus.plexus.archiver.ArchiverException Archiver 
Exception.
-     * @throws org.codehaus.plexus.archiver.jar.ManifestException Manifest 
Exception.
-     * @throws java.io.IOException IO Exception.
-     * @throws org.apache.maven.artifact.DependencyResolutionRequiredException 
Dependency resolution exception.
+     * @throws MavenArchiverException Archiver Exception.
      */
-    public void createArchive(
-            MavenSession session, MavenProject project, 
MavenArchiveConfiguration archiveConfiguration)
-            throws ManifestException, IOException, 
DependencyResolutionRequiredException {
+    public void createArchive(Session session, Project project, 
MavenArchiveConfiguration archiveConfiguration)
+            throws MavenArchiverException {
+        try {
+            doCreateArchive(session, project, archiveConfiguration);
+        } catch (ManifestException | IOException e) {
+            throw new MavenArchiverException(e);
+        }
+    }
+
+    public void doCreateArchive(Session session, Project project, 
MavenArchiveConfiguration archiveConfiguration)
+            throws ManifestException, IOException {
         // we have to clone the project instance so we can write out the pom 
with the deployment version,
         // without impacting the main project instance...
-        MavenProject workingProject = project.clone();
-
         boolean forced = archiveConfiguration.isForced();
         if (archiveConfiguration.isAddMavenDescriptor()) {
             // 
----------------------------------------------------------------------
@@ -546,26 +522,38 @@ public class MavenArchiver {
             // POM information without the use of maven tools can do so.
             // 
----------------------------------------------------------------------
 
-            if (workingProject.getArtifact().isSnapshot()) {
-                
workingProject.setVersion(workingProject.getArtifact().getVersion());
-            }
+            String groupId = project.getGroupId();
 
-            String groupId = workingProject.getGroupId();
+            String artifactId = project.getArtifactId();
 
-            String artifactId = workingProject.getArtifactId();
+            String version;
+            if (project.getPomArtifact().isSnapshot()) {
+                version = project.getPomArtifact().getVersion().toString();
+            } else {
+                version = project.getVersion();
+            }
 
-            archiver.addFile(project.getFile(), "META-INF/maven/" + groupId + 
"/" + artifactId + "/pom.xml");
+            archiver.addFile(
+                    project.getPomPath().toFile(), "META-INF/maven/" + groupId 
+ "/" + artifactId + "/pom.xml");
 
             // 
----------------------------------------------------------------------
             // Create pom.properties file
             // 
----------------------------------------------------------------------
 
-            File customPomPropertiesFile = 
archiveConfiguration.getPomPropertiesFile();
-            File dir = new File(workingProject.getBuild().getDirectory(), 
"maven-archiver");
-            File pomPropertiesFile = new File(dir, "pom.properties");
+            Path customPomPropertiesFile = 
archiveConfiguration.getPomPropertiesFile();
+            Path dir = Paths.get(project.getBuild().getDirectory(), 
"maven-archiver");
+            Path pomPropertiesFile = dir.resolve("pom.properties");
 
             new PomPropertiesUtil()
-                    .createPomProperties(workingProject, archiver, 
customPomPropertiesFile, pomPropertiesFile, forced);
+                    .createPomProperties(
+                            session,
+                            groupId,
+                            artifactId,
+                            version,
+                            archiver,
+                            customPomPropertiesFile,
+                            pomPropertiesFile,
+                            forced);
         }
 
         // 
----------------------------------------------------------------------
@@ -573,42 +561,22 @@ public class MavenArchiver {
         // 
----------------------------------------------------------------------
 
         archiver.setMinimalDefaultManifest(true);
-
-        File manifestFile = archiveConfiguration.getManifestFile();
-
+        Path manifestFile = archiveConfiguration.getManifestFile();
         if (manifestFile != null) {
-            archiver.setManifest(manifestFile);
+            archiver.setManifest(manifestFile.toFile());
         }
-
-        Manifest manifest = getManifest(session, workingProject, 
archiveConfiguration);
-
+        Manifest manifest = getManifest(session, project, 
archiveConfiguration);
         // Configure the jar
         archiver.addConfiguredManifest(manifest);
-
         archiver.setCompress(archiveConfiguration.isCompress());
-
         
archiver.setRecompressAddedZips(archiveConfiguration.isRecompressAddedZips());
-
-        archiver.setIndex(archiveConfiguration.isIndex());
-
         archiver.setDestFile(archiveFile);
-
-        // make the archiver index the jars on the classpath, if we are adding 
that to the manifest
-        if (archiveConfiguration.getManifest().isAddClasspath()) {
-            List<String> artifacts = project.getRuntimeClasspathElements();
-            for (String artifact : artifacts) {
-                File f = new File(artifact);
-                archiver.addConfiguredIndexJars(f);
-            }
-        }
-
         archiver.setForced(forced);
         if (!archiveConfiguration.isForced() && archiver.isSupportingForced()) 
{
             // TODO Should issue a warning here, but how do we get a logger?
             // TODO getLog().warn(
             // "Forced build is disabled, but disabling the forced mode isn't 
supported by the archiver." );
         }
-
         String automaticModuleName = 
manifest.getMainSection().getAttributeValue("Automatic-Module-Name");
         if (automaticModuleName != null) {
             if (!isValidModuleName(automaticModuleName)) {
@@ -631,13 +599,13 @@ public class MavenArchiver {
         }
     }
 
-    private void handleBuildEnvironmentEntries(MavenSession session, Manifest 
m, Map<String, String> entries)
+    private void handleBuildEnvironmentEntries(Session session, Manifest m, 
Map<String, String> entries)
             throws ManifestException {
         addManifestAttribute(
                 m,
                 entries,
                 "Build-Tool",
-                session != null ? 
session.getSystemProperties().getProperty("maven.build.version") : "Apache 
Maven");
+                session != null ? 
session.getSystemProperties().get("maven.build.version") : "Apache Maven");
         addManifestAttribute(
                 m,
                 entries,
@@ -654,18 +622,6 @@ public class MavenArchiver {
                         System.getProperty("os.arch")));
     }
 
-    private Artifact findArtifactWithFile(Set<Artifact> artifacts, File file) {
-        for (Artifact artifact : artifacts) {
-            // normally not null but we can check
-            if (artifact.getFile() != null) {
-                if (artifact.getFile().equals(file)) {
-                    return artifact;
-                }
-            }
-        }
-        return null;
-    }
-
     private static String getCreatedByVersion(String groupId, String 
artifactId) {
         final Properties properties = 
loadOptionalProperties(MavenArchiver.class.getResourceAsStream(
                 "/META-INF/maven/" + groupId + "/" + artifactId + 
"/pom.properties"));
@@ -718,39 +674,6 @@ public class MavenArchiver {
         this.buildJdkSpecDefaultEntry = buildJdkSpecDefaultEntry;
     }
 
-    /**
-     * Parse output timestamp configured for Reproducible Builds' 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>.
-     *
-     * @param outputTimestamp the value of 
<code>${project.build.outputTimestamp}</code> (may be <code>null</code>)
-     * @return the parsed timestamp, may be <code>null</code> if 
<code>null</code> input or input contains only 1
-     *         character
-     * @since 3.5.0
-     * @throws IllegalArgumentException if the outputTimestamp is neither ISO 
8601 nor an integer, or it's not within
-     *             the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
-     * @deprecated Use {@link #parseBuildOutputTimestamp(String)} instead.
-     */
-    @Deprecated
-    public Date parseOutputTimestamp(String outputTimestamp) {
-        return 
parseBuildOutputTimestamp(outputTimestamp).map(Date::from).orElse(null);
-    }
-
-    /**
-     * Configure Reproducible Builds archive creation if a timestamp is 
provided.
-     *
-     * @param outputTimestamp the value of {@code 
${project.build.outputTimestamp}} (may be {@code null})
-     * @return the parsed timestamp as {@link java.util.Date}
-     * @since 3.5.0
-     * @see #parseOutputTimestamp
-     * @deprecated Use {@link #configureReproducibleBuild(String)} instead.
-     */
-    @Deprecated
-    public Date configureReproducible(String outputTimestamp) {
-        configureReproducibleBuild(outputTimestamp);
-        return parseOutputTimestamp(outputTimestamp);
-    }
-
     /**
      * Parse output timestamp configured for Reproducible Builds' archive 
entries.
      *
diff --git 
a/src/main/java/org/apache/maven/archiver/MavenArchiverException.java 
b/src/main/java/org/apache/maven/archiver/MavenArchiverException.java
new file mode 100644
index 0000000..798981e
--- /dev/null
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiverException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.maven.archiver;
+
+import org.apache.maven.api.services.MavenException;
+
+public class MavenArchiverException extends MavenException {
+    public MavenArchiverException() {}
+
+    public MavenArchiverException(String message) {
+        super(message);
+    }
+
+    public MavenArchiverException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public MavenArchiverException(Throwable cause) {
+        super(cause);
+    }
+}
diff --git a/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java 
b/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
index 1b5b768..58266d7 100644
--- a/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
+++ b/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
@@ -19,20 +19,21 @@
 package org.apache.maven.archiver;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.Session;
 import org.codehaus.plexus.archiver.Archiver;
 
 /**
@@ -43,16 +44,16 @@ import org.codehaus.plexus.archiver.Archiver;
  * @version $Id: $Id
  */
 public class PomPropertiesUtil {
-    private Properties loadPropertiesFile(File file) throws IOException {
+    private Properties loadPropertiesFile(Path file) throws IOException {
         Properties fileProps = new Properties();
-        try (InputStream istream = Files.newInputStream(file.toPath())) {
+        try (InputStream istream = Files.newInputStream(file)) {
             fileProps.load(istream);
             return fileProps;
         }
     }
 
-    private boolean sameContents(Properties props, File file) throws 
IOException {
-        if (!file.isFile()) {
+    private boolean sameContents(Properties props, Path file) throws 
IOException {
+        if (!Files.isRegularFile(file)) {
             return false;
         }
 
@@ -60,17 +61,17 @@ public class PomPropertiesUtil {
         return fileProps.equals(props);
     }
 
-    private void createPropertiesFile(Properties properties, File outputFile, 
boolean forceCreation)
+    private void createPropertiesFile(Properties properties, Path outputFile, 
boolean forceCreation)
             throws IOException {
-        File outputDir = outputFile.getParentFile();
-        if (outputDir != null && !outputDir.isDirectory() && 
!outputDir.mkdirs()) {
-            throw new IOException("Failed to create directory: " + outputDir);
+        Path outputDir = outputFile.getParent();
+        if (outputDir != null && !Files.isDirectory(outputDir)) {
+            Files.createDirectories(outputDir);
         }
         if (!forceCreation && sameContents(properties, outputFile)) {
             return;
         }
 
-        try (PrintWriter pw = new PrintWriter(outputFile, "ISO-8859-1");
+        try (PrintWriter pw = new PrintWriter(outputFile.toFile(), 
StandardCharsets.ISO_8859_1.name());
                 StringWriter sw = new StringWriter()) {
 
             properties.store(sw, null);
@@ -95,50 +96,47 @@ public class PomPropertiesUtil {
     /**
      * Creates the pom.properties file.
      *
-     * @param session {@link org.apache.maven.execution.MavenSession}
-     * @param project {@link org.apache.maven.project.MavenProject}
+     * @param session {@link org.apache.maven.api.Session}
+     * @param project {@link org.apache.maven.api.Project}
      * @param archiver {@link org.codehaus.plexus.archiver.Archiver}
      * @param customPomPropertiesFile optional custom pom properties file
      * @param pomPropertiesFile The pom properties file.
      * @param forceCreation force creation true/false
      * @throws org.codehaus.plexus.archiver.ArchiverException archiver 
exception.
      * @throws java.io.IOException IO exception.
-     * @deprecated please use {@link #createPomProperties(MavenProject, 
Archiver, File, File, boolean)}
      */
-    @Deprecated
     public void createPomProperties(
-            MavenSession session,
-            MavenProject project,
+            Session session,
+            Project project,
             Archiver archiver,
-            File customPomPropertiesFile,
-            File pomPropertiesFile,
+            Path customPomPropertiesFile,
+            Path pomPropertiesFile,
             boolean forceCreation)
             throws IOException {
-        createPomProperties(project, archiver, customPomPropertiesFile, 
pomPropertiesFile, forceCreation);
+        final String groupId = project.getGroupId();
+        final String artifactId = project.getArtifactId();
+        final String version = project.getVersion();
+        createPomProperties(
+                session,
+                groupId,
+                artifactId,
+                version,
+                archiver,
+                customPomPropertiesFile,
+                pomPropertiesFile,
+                forceCreation);
     }
 
-    /**
-     * Creates the pom.properties file.
-     *
-     * @param project                 {@link 
org.apache.maven.project.MavenProject}
-     * @param archiver                {@link 
org.codehaus.plexus.archiver.Archiver}
-     * @param customPomPropertiesFile optional custom pom properties file
-     * @param pomPropertiesFile       The pom properties file.
-     * @param forceCreation           force creation true/false
-     * @throws org.codehaus.plexus.archiver.ArchiverException archiver 
exception.
-     * @throws java.io.IOException                            IO exception.
-     */
     public void createPomProperties(
-            MavenProject project,
+            Session session,
+            String groupId,
+            String artifactId,
+            String version,
             Archiver archiver,
-            File customPomPropertiesFile,
-            File pomPropertiesFile,
+            Path customPomPropertiesFile,
+            Path pomPropertiesFile,
             boolean forceCreation)
             throws IOException {
-        final String groupId = project.getGroupId();
-        final String artifactId = project.getArtifactId();
-        final String version = project.getVersion();
-
         Properties p;
 
         if (customPomPropertiesFile != null) {
@@ -155,6 +153,7 @@ public class PomPropertiesUtil {
 
         createPropertiesFile(p, pomPropertiesFile, forceCreation);
 
-        archiver.addFile(pomPropertiesFile, "META-INF/maven/" + groupId + "/" 
+ artifactId + "/pom.properties");
+        archiver.addFile(
+                pomPropertiesFile.toFile(), "META-INF/maven/" + groupId + "/" 
+ artifactId + "/pom.properties");
     }
 }
diff --git 
a/src/test/java/org/apache/maven/archiver/MavenArchiveConfigurationTest.java 
b/src/test/java/org/apache/maven/archiver/MavenArchiveConfigurationTest.java
index 1756c03..994a4c7 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiveConfigurationTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiveConfigurationTest.java
@@ -39,7 +39,6 @@ class MavenArchiveConfigurationTest {
         archive.setManifest(new ManifestConfiguration());
         archive.setForced(false);
         archive.setCompress(false);
-        archive.setIndex(false);
     }
 
     @Test
diff --git a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java 
b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
index 6c74558..289d8b5 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
@@ -29,33 +29,27 @@ import java.nio.file.Paths;
 import java.nio.file.attribute.FileTime;
 import java.time.Instant;
 import java.time.format.DateTimeParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.stream.Stream;
 import java.util.zip.ZipEntry;
 
-import org.apache.maven.artifact.Artifact;
+import org.apache.maven.api.*;
+import org.apache.maven.api.model.Build;
+import org.apache.maven.api.model.Model;
+import org.apache.maven.api.model.Organization;
+import org.apache.maven.api.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
+import org.apache.maven.api.plugin.testing.stubs.SessionMock;
+import org.apache.maven.api.services.DependencyResolver;
+import org.apache.maven.api.services.DependencyResolverResult;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Organization;
-import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.EnabledForJreRange;
 import org.junit.jupiter.api.condition.JRE;
@@ -68,10 +62,29 @@ import org.junit.jupiter.params.provider.ValueSource;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class MavenArchiverTest {
+
+    Session session;
+    DependencyResolver dependencyResolver;
+    DependencyResolverResult dependencyResolverResult;
+    Map<Dependency, Path> dependencies = new LinkedHashMap<>();
+
+    @BeforeEach
+    void setup() {
+        session = getDummySession();
+        dependencyResolver = mock(DependencyResolver.class);
+        
when(session.getService(DependencyResolver.class)).thenReturn(dependencyResolver);
+        dependencyResolverResult = mock(DependencyResolverResult.class);
+        when(dependencyResolver.resolve(eq(session), any(Project.class), 
eq(PathScope.MAIN_RUNTIME)))
+                .thenReturn(dependencyResolverResult);
+        
when(dependencyResolverResult.getDependencies()).thenReturn(dependencies);
+    }
+
     static class ArtifactComparator implements Comparator<Artifact> {
         public int compare(Artifact o1, Artifact o2) {
             return o1.getArtifactId().compareTo(o2.getArtifactId());
@@ -104,86 +117,6 @@ class MavenArchiverTest {
         assertThat(MavenArchiver.isValidModuleName(value)).isTrue();
     }
 
-    @Test
-    void testGetManifestExtensionList() throws Exception {
-        MavenArchiver archiver = new MavenArchiver();
-
-        MavenSession session = getDummySession();
-
-        Model model = new Model();
-        model.setArtifactId("dummy");
-
-        MavenProject project = new MavenProject(model);
-        // we need to sort the artifacts for test purposes
-        Set<Artifact> artifacts = new TreeSet<>(new ArtifactComparator());
-        project.setArtifacts(artifacts);
-
-        // there should be a mock or a setter for this field.
-        ManifestConfiguration config = new ManifestConfiguration() {
-            public boolean isAddExtensions() {
-                return true;
-            }
-        };
-
-        Manifest manifest = archiver.getManifest(session, project, config);
-
-        assertThat(manifest.getMainAttributes()).isNotNull();
-
-        
assertThat(manifest.getMainAttributes().getValue("Extension-List")).isNull();
-
-        Artifact artifact1 = mock(Artifact.class);
-        when(artifact1.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact1.getArtifactId()).thenReturn("dummy1");
-        when(artifact1.getVersion()).thenReturn("1.0");
-        when(artifact1.getType()).thenReturn("dll");
-        when(artifact1.getScope()).thenReturn("compile");
-
-        artifacts.add(artifact1);
-
-        manifest = archiver.getManifest(session, project, config);
-
-        
assertThat(manifest.getMainAttributes().getValue("Extension-List")).isNull();
-
-        Artifact artifact2 = mock(Artifact.class);
-        when(artifact2.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact2.getArtifactId()).thenReturn("dummy2");
-        when(artifact2.getVersion()).thenReturn("1.0");
-        when(artifact2.getType()).thenReturn("jar");
-        when(artifact2.getScope()).thenReturn("compile");
-
-        artifacts.add(artifact2);
-
-        manifest = archiver.getManifest(session, project, config);
-
-        
assertThat(manifest.getMainAttributes().getValue("Extension-List")).isEqualTo("dummy2");
-
-        Artifact artifact3 = mock(Artifact.class);
-        when(artifact3.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact3.getArtifactId()).thenReturn("dummy3");
-        when(artifact3.getVersion()).thenReturn("1.0");
-        when(artifact3.getType()).thenReturn("jar");
-        when(artifact3.getScope()).thenReturn("test");
-
-        artifacts.add(artifact3);
-
-        manifest = archiver.getManifest(session, project, config);
-
-        
assertThat(manifest.getMainAttributes().getValue("Extension-List")).isEqualTo("dummy2");
-
-        Artifact artifact4 = mock(Artifact.class);
-        when(artifact4.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact4.getArtifactId()).thenReturn("dummy4");
-        when(artifact4.getVersion()).thenReturn("1.0");
-        when(artifact4.getType()).thenReturn("jar");
-        when(artifact4.getScope()).thenReturn("compile");
-
-        artifacts.add(artifact4);
-
-        manifest = archiver.getManifest(session, project, config);
-
-        
assertThat(manifest.getMainAttributes().getValue("Extension-List")).isEqualTo("dummy2
 dummy4");
-    }
-
     @Test
     void testMultiClassPath() throws Exception {
         final File tempFile = File.createTempFile("maven-archiver-test-", 
".jar");
@@ -191,23 +124,15 @@ class MavenArchiverTest {
         try {
             MavenArchiver archiver = new MavenArchiver();
 
-            MavenSession session = getDummySession();
-
-            Model model = new Model();
-            model.setArtifactId("dummy");
+            dependencies.put(mock(Dependency.class), 
tempFile.getAbsoluteFile().toPath());
 
-            MavenProject project = new MavenProject(model) {
-                public List<String> getRuntimeClasspathElements() {
-                    return 
Collections.singletonList(tempFile.getAbsolutePath());
-                }
-            };
+            ProjectStub project = new ProjectStub();
+            project.setModel(Model.newBuilder().artifactId("dummy").build());
 
             // there should be a mock or a setter for this field.
-            ManifestConfiguration manifestConfig = new ManifestConfiguration() 
{
-                public boolean isAddClasspath() {
-                    return true;
-                }
-            };
+            ManifestConfiguration manifestConfig = new ManifestConfiguration();
+            manifestConfig.setAddClasspath(true);
+            manifestConfig.setClasspathLayoutType(null);
 
             MavenArchiveConfiguration archiveConfiguration = new 
MavenArchiveConfiguration();
             archiveConfiguration.setManifest(manifestConfig);
@@ -233,8 +158,7 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
 
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(false);
@@ -274,8 +198,7 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
 
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
@@ -296,15 +219,14 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        ProjectStub project = getDummyProject();
 
         String ls = System.getProperty("line.separator");
-        project.setDescription("foo " + ls + " bar ");
+        project.setModel(project.getModel().withDescription("foo " + ls + " 
bar "));
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.getManifest().setAddDefaultImplementationEntries(true);
-        config.addManifestEntry("Description", project.getDescription());
+        config.addManifestEntry("Description", 
project.getModel().getDescription());
         archiver.createArchive(session, project, config);
         assertThat(jarFile).exists();
 
@@ -323,19 +245,18 @@ class MavenArchiverTest {
     }
 
     @Test
-    void testDashesInClassPath_MSHARED_134() throws Exception {
+    void testDashesInClassPath_MSHARED_134()
+            throws IOException, ManifestException, 
DependencyResolutionRequiredException {
         File jarFile = new File("target/test/dummyWithDashes.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
 
-        Set<Artifact> artifacts =
-                getArtifacts(getMockArtifact1(), getArtifactWithDot(), 
getMockArtifact2(), getMockArtifact3());
+        useArtifacts(getMockArtifact1(), getArtifactWithDot(), 
getMockArtifact2(), getMockArtifact3());
 
-        project.setArtifacts(artifacts);
+        //        project.setArtifacts(artifacts);
 
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(false);
@@ -351,18 +272,15 @@ class MavenArchiverTest {
     }
 
     @Test
-    void testDashesInClassPath_MSHARED_182() throws Exception {
+    void testDashesInClassPath_MSHARED_182()
+            throws IOException, ManifestException, 
DependencyResolutionRequiredException {
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
 
-        Set<Artifact> artifacts =
-                getArtifacts(getMockArtifact1(), getArtifactWithDot(), 
getMockArtifact2(), getMockArtifact3());
-
-        project.setArtifacts(artifacts);
+        useArtifacts(getMockArtifact1(), getArtifactWithDot(), 
getMockArtifact2(), getMockArtifact3());
 
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(false);
@@ -389,15 +307,14 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        ProjectStub project = getDummyProject();
 
         String ls = System.getProperty("line.separator");
-        project.setDescription("foo " + ls + " bar ");
+        project.setModel(project.getModel().withDescription("foo " + ls + " 
bar "));
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.getManifest().setAddDefaultImplementationEntries(true);
-        config.addManifestEntry("Description", project.getDescription());
+        config.addManifestEntry("Description", 
project.getModel().getDescription());
         // config.addManifestEntry( "EntryWithTab", " foo tab " + ( '\u0009' ) 
+ ( '\u0009' ) // + " bar tab" + ( //
         // '\u0009' // ) );
         archiver.createArchive(session, project, config);
@@ -405,7 +322,7 @@ class MavenArchiverTest {
 
         final Manifest manifest = getJarFileManifest(jarFile);
         Attributes attributes = manifest.getMainAttributes();
-        assertThat(project.getDescription().indexOf(ls)).isGreaterThan(0);
+        
assertThat(project.getModel().getDescription().indexOf(ls)).isGreaterThan(0);
         Attributes.Name description = new Attributes.Name("Description");
         String value = attributes.getValue(description);
         assertThat(value).isNotNull();
@@ -419,13 +336,13 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.getManifest().setAddDefaultImplementationEntries(true);
         config.getManifest().setAddDefaultSpecificationEntries(true);
 
-        MavenSession session = getDummySessionWithoutMavenVersion();
+        Session session = getDummySessionWithoutMavenVersion();
         archiver.createArchive(session, project, config);
         assertThat(jarFile).exists();
         Attributes manifest = getJarFileManifest(jarFile).getMainAttributes();
@@ -449,8 +366,7 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.getManifest().setAddDefaultEntries(false);
@@ -472,8 +388,7 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.getManifest().setAddDefaultImplementationEntries(true);
@@ -546,8 +461,7 @@ class MavenArchiverTest {
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
 
         Map<String, String> manifestEntries = new HashMap<>();
@@ -556,21 +470,19 @@ class MavenArchiverTest {
 
         try {
             archiver.createArchive(session, project, config);
-        } catch (ManifestException e) {
-            assertThat(e.getMessage()).isEqualTo("Invalid automatic module 
name: '123.in-valid.new.name'");
+        } catch (MavenArchiverException e) {
+            assertThat(e.getMessage()).contains("Invalid automatic module 
name: '123.in-valid.new.name'");
         }
     }
 
-    /*
-     * Test to make sure that manifest sections are present in the manifest 
prior to the archive has been created.
-     */
+    //
+    // Test to make sure that manifest sections are present in the manifest 
prior to the archive has been created.
+    //
     @Test
     void testManifestSections() throws Exception {
         MavenArchiver archiver = new MavenArchiver();
 
-        MavenSession session = getDummySession();
-
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
 
         ManifestSection manifestSection = new ManifestSection();
@@ -597,8 +509,7 @@ class MavenArchiverTest {
 
     @Test
     void testDefaultClassPathValue() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -623,15 +534,9 @@ class MavenArchiverTest {
                 .containsExactly("dummy1-1.0.jar", "dummy2-1.5.jar", 
"dummy3-2.0-classifier.jar");
     }
 
-    private void deleteAndAssertNotPresent(File jarFile) {
-        jarFile.delete();
-        assertThat(jarFile).doesNotExist();
-    }
-
     @Test
     void testDefaultClassPathValue_WithSnapshot() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProjectWithSnapshot();
+        Project project = getDummyProjectWithSnapshot();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -659,8 +564,7 @@ class MavenArchiverTest {
 
     @Test
     void testMavenRepoClassPathValue() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -696,8 +600,7 @@ class MavenArchiverTest {
 
     @Test
     void 
shouldCreateArchiveWithSimpleClassPathLayoutWhileSettingSimpleLayoutExplicit() 
throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy-explicit-simple.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -729,8 +632,7 @@ class MavenArchiverTest {
 
     @Test
     void shouldCreateArchiveCustomerLayoutSimple() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy-custom-layout-simple.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -763,8 +665,7 @@ class MavenArchiverTest {
 
     @Test
     void shouldCreateArchiveCustomLayoutSimpleNonUnique() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new 
File("target/test/dummy-custom-layout-simple-non-unique.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -797,8 +698,7 @@ class MavenArchiverTest {
 
     @Test
     void shouldCreateArchiveCustomLayoutRepository() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy-custom-layout-repo.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -837,8 +737,7 @@ class MavenArchiverTest {
 
     @Test
     void shouldCreateArchiveCustomLayoutRepositoryNonUnique() throws Exception 
{
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new 
File("target/test/dummy-custom-layout-repo-non-unique.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -877,8 +776,7 @@ class MavenArchiverTest {
 
     @Test
     void shouldCreateArchiveWithSimpleClassPathLayoutUsingDefaults() throws 
Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy-defaults.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -908,8 +806,7 @@ class MavenArchiverTest {
 
     @Test
     void testMavenRepoClassPathValue_WithSnapshot() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProjectWithSnapshot();
+        Project project = getDummyProjectWithSnapshot();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -945,8 +842,7 @@ class MavenArchiverTest {
 
     @Test
     void testCustomClassPathValue() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -985,8 +881,7 @@ class MavenArchiverTest {
 
     @Test
     void testCustomClassPathValue_WithSnapshotResolvedVersion() throws 
Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProjectWithSnapshot();
+        Project project = getDummyProjectWithSnapshot();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
@@ -1024,8 +919,7 @@ class MavenArchiverTest {
 
     @Test
     void testCustomClassPathValue_WithSnapshotForcingBaseVersion() throws 
Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProjectWithSnapshot();
+        Project project = getDummyProjectWithSnapshot();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -1061,8 +955,7 @@ class MavenArchiverTest {
 
     @Test
     void testDefaultPomProperties() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
@@ -1095,14 +988,13 @@ class MavenArchiverTest {
 
     @Test
     void testCustomPomProperties() throws Exception {
-        MavenSession session = getDummySession();
-        MavenProject project = getDummyProject();
+        Project project = getDummyProject();
         File jarFile = new File("target/test/dummy.jar");
         JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
 
         MavenArchiver archiver = getMavenArchiver(jarArchiver);
 
-        File customPomPropertiesFile = new 
File("src/test/resources/custom-pom.properties");
+        Path customPomPropertiesFile = 
Paths.get("src/test/resources/custom-pom.properties");
         MavenArchiveConfiguration config = new MavenArchiveConfiguration();
         config.setForced(true);
         config.setPomPropertiesFile(customPomPropertiesFile);
@@ -1142,149 +1034,172 @@ class MavenArchiverTest {
     // common methods for testing
     // ----------------------------------------
 
-    private MavenProject getDummyProject() throws Exception {
-        MavenProject project = getMavenProject();
-
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact.getArtifactId()).thenReturn("dummy");
-        when(artifact.getVersion()).thenReturn("0.1.1");
-        when(artifact.getBaseVersion()).thenReturn("0.1.2");
-        when(artifact.getSelectedVersion()).thenReturn(new 
DefaultArtifactVersion("0.1.1"));
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getArtifactHandler()).thenReturn(new 
DefaultArtifactHandler("jar"));
-        project.setArtifact(artifact);
-
-        Set<Artifact> artifacts = getArtifacts(getMockArtifact1Release(), 
getMockArtifact2(), getMockArtifact3());
-        project.setArtifacts(artifacts);
+    private ProjectStub getDummyProject() {
+        ProjectStub project = getProject();
+        File pomFile = new File("src/test/resources/pom.xml");
+        pomFile.setLastModified(System.currentTimeMillis() - 60000L);
+        project.setPomPath(pomFile.toPath());
+        Model model = Model.newBuilder()
+                .groupId("org.apache.dummy")
+                .artifactId("dummy")
+                .version("0.1.1")
+                .name("archiver test")
+                .url("https://maven.apache.org";)
+                .organization(Organization.newBuilder().name("Apache").build())
+                .build(Build.newBuilder()
+                        .directory("target")
+                        .outputDirectory("target")
+                        .build())
+                .build();
+        project.setModel(model);
+        ArtifactStub artifact = new ArtifactStub();
+        artifact.setGroupId("org.apache.dummy");
+        artifact.setArtifactId("dummy");
+        artifact.setVersion("0.1.1");
+        artifact.setExtension("jar");
+        project.setMainArtifact(artifact);
+
+        useArtifacts(getMockArtifact1Release(), getMockArtifact2(), 
getMockArtifact3());
 
         return project;
     }
 
-    private MavenProject getMavenProject() {
-        Model model = new Model();
-        model.setGroupId("org.apache.dummy");
-        model.setArtifactId("dummy");
-        model.setVersion("0.1.1");
+    private ProjectStub getProject() {
+        Model model = Model.newBuilder()
+                .groupId("org.apache.dummy")
+                .artifactId("dummy")
+                .version("0.1.1")
+                .build();
+
+        ProjectStub project = new ProjectStub();
+        project.setModel(model);
+        //        project.setExtensionArtifacts(Collections.emptySet());
+        //        
project.setRemoteArtifactRepositories(Collections.emptyList());
+        //        
project.setPluginArtifactRepositories(Collections.emptyList());
+        return project;
+    }
 
-        final MavenProject project = new MavenProject(model);
-        project.setExtensionArtifacts(Collections.emptySet());
-        project.setRemoteArtifactRepositories(Collections.emptyList());
-        project.setPluginArtifactRepositories(Collections.emptyList());
-        project.setName("archiver test");
+    private DependencyStub getMockArtifact3() {
+        DependencyStub artifact3 = new DependencyStub();
+        artifact3.setGroupId("org.apache.dummy.bar");
+        artifact3.setArtifactId("dummy3");
+        artifact3.setVersion("2.0");
+        //        artifact3.setScope("runtime");
+        artifact3.setExtension("jar");
+        artifact3.setClassifier("classifier");
+        artifact3.setPath(getClasspathFile(artifact3.getArtifactId() + "-" + 
artifact3.getVersion() + ".jar"));
+        return artifact3;
+    }
 
+    private Project getDummyProjectWithSnapshot() {
+        ProjectStub project = getProject();
         File pomFile = new File("src/test/resources/pom.xml");
-        project.setFile(pomFile);
-
-        Build build = new Build();
-        build.setDirectory("target");
-        build.setOutputDirectory("target");
-        project.setBuild(build);
+        pomFile.setLastModified(System.currentTimeMillis() - 60000L);
+        project.setPomPath(pomFile.toPath());
+        project.setModel(Model.newBuilder()
+                .groupId("org.apache.dummy")
+                .artifactId("dummy")
+                .version("0.1.1")
+                .name("archiver test")
+                .organization(Organization.newBuilder().name("Apache").build())
+                .build(Build.newBuilder()
+                        .directory("target")
+                        .outputDirectory("target")
+                        .build())
+                .build());
+
+        ArtifactStub artifact = new ArtifactStub();
+        artifact.setGroupId("org.apache.dummy");
+        artifact.setArtifactId("dummy");
+        artifact.setVersion("0.1.1");
+        artifact.setExtension("jar");
+        project.setMainArtifact(artifact);
+
+        useArtifacts(getMockArtifact1(), getMockArtifact2(), 
getMockArtifact3());
 
-        Organization organization = new Organization();
-        organization.setName("Apache");
-        project.setOrganization(organization);
         return project;
     }
 
-    private Artifact getMockArtifact3() {
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy.bar");
-        when(artifact.getArtifactId()).thenReturn("dummy3");
-        when(artifact.getVersion()).thenReturn("2.0");
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getScope()).thenReturn("runtime");
-        when(artifact.getClassifier()).thenReturn("classifier");
-        File file = getClasspathFile(artifact.getArtifactId() + "-" + 
artifact.getVersion() + ".jar");
-        when(artifact.getFile()).thenReturn(file);
-        ArtifactHandler artifactHandler = mock(ArtifactHandler.class);
-        when(artifactHandler.isAddedToClasspath()).thenReturn(true);
-        when(artifactHandler.getExtension()).thenReturn("jar");
-        when(artifact.getArtifactHandler()).thenReturn(artifactHandler);
-        return artifact;
-    }
+    private ArtifactHandler getMockArtifactHandler() {
+        return new ArtifactHandler() {
 
-    private MavenProject getDummyProjectWithSnapshot() throws Exception {
-        MavenProject project = getMavenProject();
+            public String getClassifier() {
+                return null;
+            }
 
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact.getArtifactId()).thenReturn("dummy");
-        when(artifact.getVersion()).thenReturn("0.1.1");
-        when(artifact.getBaseVersion()).thenReturn("0.1.1");
-        when(artifact.getSelectedVersion()).thenReturn(new 
DefaultArtifactVersion("0.1.1"));
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getScope()).thenReturn("compile");
-        when(artifact.getArtifactHandler()).thenReturn(new 
DefaultArtifactHandler("jar"));
-        project.setArtifact(artifact);
+            public String getDirectory() {
+                return null;
+            }
 
-        Set<Artifact> artifacts = getArtifacts(getMockArtifact1(), 
getMockArtifact2(), getMockArtifact3());
-        project.setArtifacts(artifacts);
+            public String getExtension() {
+                return "jar";
+            }
 
-        return project;
+            public String getLanguage() {
+                return null;
+            }
+
+            public String getPackaging() {
+                return null;
+            }
+
+            public boolean isAddedToClasspath() {
+                return true;
+            }
+
+            public boolean isIncludesDependencies() {
+                return false;
+            }
+        };
     }
 
-    private Artifact getMockArtifact2() {
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy.foo");
-        when(artifact.getArtifactId()).thenReturn("dummy2");
-        when(artifact.getVersion()).thenReturn("1.5");
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getScope()).thenReturn("runtime");
-        File file = getClasspathFile(artifact.getArtifactId() + "-" + 
artifact.getVersion() + ".jar");
-        when(artifact.getFile()).thenReturn(file);
-        ArtifactHandler artifactHandler = mock(ArtifactHandler.class);
-        when(artifactHandler.isAddedToClasspath()).thenReturn(true);
-        when(artifactHandler.getExtension()).thenReturn("jar");
-        when(artifact.getArtifactHandler()).thenReturn(artifactHandler);
-        return artifact;
+    private DependencyStub getMockArtifact2() {
+        DependencyStub artifact2 = new DependencyStub();
+        artifact2.setGroupId("org.apache.dummy.foo");
+        artifact2.setArtifactId("dummy2");
+        artifact2.setVersion("1.5");
+        artifact2.setExtension("jar");
+        //        artifact2.setScope("runtime");
+        artifact2.setPath(getClasspathFile(artifact2.getArtifactId() + "-" + 
artifact2.getVersion() + ".jar"));
+        return artifact2;
     }
 
-    private Artifact getArtifactWithDot() {
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy.foo");
-        when(artifact.getArtifactId()).thenReturn("dummy.dot");
-        when(artifact.getVersion()).thenReturn("1.5");
-        when(artifact.getScope()).thenReturn("runtime");
-        when(artifact.getArtifactHandler()).thenReturn(new 
DefaultArtifactHandler("jar"));
-        return artifact;
+    private DependencyStub getArtifactWithDot() {
+        DependencyStub artifact2 = new DependencyStub();
+        artifact2.setGroupId("org.apache.dummy.foo");
+        artifact2.setArtifactId("dummy.dot");
+        artifact2.setVersion("1.5");
+        artifact2.setExtension("jar");
+        //        artifact2.setScope("runtime");
+        artifact2.setPath(getClasspathFile(artifact2.getArtifactId() + "-" + 
artifact2.getVersion() + ".jar"));
+        return artifact2;
     }
 
-    private Artifact getMockArtifact1() {
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact.getArtifactId()).thenReturn("dummy1");
-        when(artifact.getVersion()).thenReturn("1.1-20081022.112233-1");
-        when(artifact.getBaseVersion()).thenReturn("1.1-SNAPSHOT");
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getScope()).thenReturn("runtime");
-        File file = getClasspathFile(artifact.getArtifactId() + "-" + 
artifact.getVersion() + ".jar");
-        when(artifact.getFile()).thenReturn(file);
-        ArtifactHandler artifactHandler = mock(ArtifactHandler.class);
-        when(artifactHandler.isAddedToClasspath()).thenReturn(true);
-        when(artifactHandler.getExtension()).thenReturn("jar");
-        when(artifact.getArtifactHandler()).thenReturn(artifactHandler);
-        return artifact;
+    private DependencyStub getMockArtifact1() {
+        DependencyStub artifact1 = new DependencyStub();
+        artifact1.setGroupId("org.apache.dummy");
+        artifact1.setArtifactId("dummy1");
+        artifact1.setVersion("1.1-20081022.112233-1");
+        artifact1.setBaseVersion("1.1-SNAPSHOT");
+        artifact1.setExtension("jar");
+        //        artifact1.setScope("runtime");
+        artifact1.setPath(getClasspathFile(artifact1.getArtifactId() + "-" + 
artifact1.getVersion() + ".jar"));
+        return artifact1;
     }
 
-    private Artifact getMockArtifact1Release() {
-        Artifact artifact = mock(Artifact.class);
-        when(artifact.getGroupId()).thenReturn("org.apache.dummy");
-        when(artifact.getArtifactId()).thenReturn("dummy1");
-        when(artifact.getVersion()).thenReturn("1.0");
-        when(artifact.getBaseVersion()).thenReturn("1.0.1");
-        when(artifact.getType()).thenReturn("jar");
-        when(artifact.getScope()).thenReturn("runtime");
-        File file = getClasspathFile(artifact.getArtifactId() + "-" + 
artifact.getVersion() + ".jar");
-        when(artifact.getFile()).thenReturn(file);
-        ArtifactHandler artifactHandler = mock(ArtifactHandler.class);
-        when(artifactHandler.isAddedToClasspath()).thenReturn(true);
-        when(artifactHandler.getExtension()).thenReturn("jar");
-        when(artifact.getArtifactHandler()).thenReturn(artifactHandler);
-        return artifact;
+    private DependencyStub getMockArtifact1Release() {
+        DependencyStub artifact1 = new DependencyStub();
+        artifact1.setGroupId("org.apache.dummy");
+        artifact1.setArtifactId("dummy1");
+        artifact1.setVersion("1.0");
+        artifact1.setBaseVersion("1.0.1");
+        artifact1.setExtension("jar");
+        //        artifact1.setScope("runtime");
+        artifact1.setPath(getClasspathFile(artifact1.getArtifactId() + "-" + 
artifact1.getVersion() + ".jar"));
+        return artifact1;
     }
 
-    private File getClasspathFile(String file) {
+    private Path getClasspathFile(String file) {
         URL resource = 
Thread.currentThread().getContextClassLoader().getResource(file);
         if (resource == null) {
             throw new IllegalStateException(
@@ -1293,11 +1208,11 @@ class MavenArchiverTest {
 
         URI uri = new File(resource.getPath()).toURI().normalize();
 
-        return new File(uri.getPath().replaceAll("%20", " "));
+        return new File(uri.getPath().replaceAll("%20", " ")).toPath();
     }
 
-    private MavenSession getDummySession() {
-        Properties systemProperties = new Properties();
+    private Session getDummySession() {
+        HashMap<String, String> systemProperties = new HashMap<>();
         systemProperties.put("maven.version", "3.1.1");
         systemProperties.put(
                 "maven.build.version",
@@ -1306,20 +1221,33 @@ class MavenArchiverTest {
         return getDummySession(systemProperties);
     }
 
-    private MavenSession getDummySessionWithoutMavenVersion() {
-        return getDummySession(new Properties());
+    private Session getDummySessionWithoutMavenVersion() {
+        return getDummySession(new HashMap<>());
     }
 
-    private MavenSession getDummySession(Properties systemProperties) {
-        MavenSession session = mock(MavenSession.class);
+    private Session getDummySession(Map<String, String> systemProperties) {
+        //        Date startTime = new Date();
+
+        //        MavenExecutionRequest request = new 
DefaultMavenExecutionRequest();
+        //        request.setSystemProperties(systemProperties);
+        //        request.setGoals(null);
+        //        request.setStartTime(startTime);
+        //        request.setUserSettingsFile(null);
+
+        //        MavenExecutionResult result = new 
DefaultMavenExecutionResult();
+        //
+        //        RepositorySystemSession rss = new 
DefaultRepositorySystemSession();
+
+        Session session = SessionMock.getMockSession("target/local-repo");
         when(session.getSystemProperties()).thenReturn(systemProperties);
+
         return session;
     }
 
-    private Set<Artifact> getArtifacts(Artifact... artifacts) {
-        Set<Artifact> result = new TreeSet<>(new ArtifactComparator());
-        result.addAll(Arrays.asList(artifacts));
-        return result;
+    private void useArtifacts(DependencyStub... dependencies) {
+        for (DependencyStub dependency : dependencies) {
+            this.dependencies.put(dependency, dependency.getPath());
+        }
     }
 
     public Manifest getJarFileManifest(File jarFile) throws IOException {
@@ -1330,27 +1258,34 @@ class MavenArchiverTest {
 
     @Test
     void testParseOutputTimestamp() {
-        MavenArchiver archiver = new MavenArchiver();
-
-        assertThat(archiver.parseOutputTimestamp(null)).isNull();
-        assertThat(archiver.parseOutputTimestamp("")).isNull();
-        assertThat(archiver.parseOutputTimestamp(".")).isNull();
-        assertThat(archiver.parseOutputTimestamp(" ")).isNull();
-        assertThat(archiver.parseOutputTimestamp("_")).isNull();
-        assertThat(archiver.parseOutputTimestamp("-")).isNull();
-        assertThat(archiver.parseOutputTimestamp("/")).isNull();
-        assertThat(archiver.parseOutputTimestamp("!")).isNull();
-        assertThat(archiver.parseOutputTimestamp("*")).isNull();
-
-        
assertThat(archiver.parseOutputTimestamp("1570300662").getTime()).isEqualTo(1570300662000L);
-        assertThat(archiver.parseOutputTimestamp("0").getTime()).isZero();
-        
assertThat(archiver.parseOutputTimestamp("1").getTime()).isEqualTo(1000L);
-
-        
assertThat(archiver.parseOutputTimestamp("2019-10-05T18:37:42Z").getTime())
+        assertThat(MavenArchiver.parseBuildOutputTimestamp(null)).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp(".")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp(" ")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("_")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("-")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("/")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("!")).isEmpty();
+        assertThat(MavenArchiver.parseBuildOutputTimestamp("*")).isEmpty();
+
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("1570300662").get().toEpochMilli())
+                .isEqualTo(1570300662000L);
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("0").get().toEpochMilli())
+                .isZero();
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("1").get().toEpochMilli())
+                .isEqualTo(1000L);
+
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("2019-10-05T18:37:42Z")
+                        .get()
+                        .toEpochMilli())
                 .isEqualTo(1570300662000L);
-        
assertThat(archiver.parseOutputTimestamp("2019-10-05T20:37:42+02:00").getTime())
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("2019-10-05T20:37:42+02:00")
+                        .get()
+                        .toEpochMilli())
                 .isEqualTo(1570300662000L);
-        
assertThat(archiver.parseOutputTimestamp("2019-10-05T16:37:42-02:00").getTime())
+        
assertThat(MavenArchiver.parseBuildOutputTimestamp("2019-10-05T16:37:42-02:00")
+                        .get()
+                        .toEpochMilli())
                 .isEqualTo(1570300662000L);
 
         // These must result in IAE because we expect extended ISO format only 
(ie with - separator for date and
@@ -1358,9 +1293,9 @@ class MavenArchiverTest {
         // X SimpleDateFormat accepts timezone without separator while date 
has separator, which is a mix between
         // basic (no separators, both for date and timezone) and extended 
(separator for both)
         assertThatExceptionOfType(IllegalArgumentException.class)
-                .isThrownBy(() -> 
archiver.parseOutputTimestamp("2019-10-05T20:37:42+0200"));
+                .isThrownBy(() -> 
MavenArchiver.parseBuildOutputTimestamp("2019-10-05T20:37:42+0200"));
         assertThatExceptionOfType(IllegalArgumentException.class)
-                .isThrownBy(() -> 
archiver.parseOutputTimestamp("2019-10-05T20:37:42-0200"));
+                .isThrownBy(() -> 
MavenArchiver.parseBuildOutputTimestamp("2019-10-05T20:37:42-0200"));
     }
 
     @ParameterizedTest
@@ -1436,4 +1371,65 @@ class MavenArchiverTest {
     void testShortOffset(String value, long expected) {
         
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
     }
+
+    private void deleteAndAssertNotPresent(File jarFile) {
+        jarFile.delete();
+        assertThat(jarFile).doesNotExist();
+    }
+
+    static class DependencyStub extends ArtifactStub implements Dependency {
+        Type type;
+        Map<String, String> properties;
+        DependencyScope scope;
+        boolean optional;
+        Path path;
+
+        @Override
+        public Type getType() {
+            return type;
+        }
+
+        public void setType(Type type) {
+            this.type = type;
+        }
+
+        public Map<String, String> getProperties() {
+            return properties;
+        }
+
+        public void setProperties(Map<String, String> properties) {
+            this.properties = properties;
+        }
+
+        @Override
+        public DependencyScope getScope() {
+            return scope;
+        }
+
+        public void setScope(DependencyScope scope) {
+            this.scope = scope;
+        }
+
+        @Override
+        public boolean isOptional() {
+            return optional;
+        }
+
+        public void setOptional(boolean optional) {
+            this.optional = optional;
+        }
+
+        @Override
+        public DependencyCoordinate toCoordinate() {
+            return null;
+        }
+
+        public Path getPath() {
+            return path;
+        }
+
+        public void setPath(Path path) {
+            this.path = path;
+        }
+    }
 }


Reply via email to