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-source-plugin.git

commit 0853c4551866fb3183935f45ec8740fbac9ea6fc
Author: Guillaume Nodet <[email protected]>
AuthorDate: Mon Jun 17 17:47:45 2024 +0200

    [MSOURCES-149] Switch to the Maven 4 API
    
    IT MSOURCES-140 is broken because of 
https://github.com/apache/maven/pull/1587
---
 .github/workflows/maven-verify.yml                 |   4 +
 pom.xml                                            |  78 ++++--
 src/it/MSOURCES-121/verify.groovy                  |   3 +-
 src/it/MSOURCES-140/invoker.properties             |   3 +
 src/it/MSOURCES-140/verify.groovy                  |   2 +-
 src/it/MSOURCES-62/pom.xml                         |   1 -
 .../plugins/source/AbstractSourceJarMojo.java      | 270 +++++++++++----------
 .../plugins/source/AggregatorSourceJarMojo.java    |  16 +-
 .../apache/maven/plugins/source/Archivers.java}    |  17 +-
 .../apache/maven/plugins/source/SourceJarMojo.java |   9 +-
 .../maven/plugins/source/SourceJarNoForkMojo.java  |  21 +-
 .../plugins/source/TestSourceGeneratedJarMojo.java |   9 +-
 .../maven/plugins/source/TestSourceJarMojo.java    |   9 +-
 .../plugins/source/TestSourceJarNoForkMojo.java    |  21 +-
 .../source/AbstractSourcePluginTestCase.java       | 111 +--------
 .../maven/plugins/source/SourceJarMojoTest.java    | 229 +++++++++++------
 .../plugins/source/TestSourceJarMojoTest.java      | 173 ++++++++-----
 .../source/stubs/DefaultArtifactHandlerStub.java   |  59 -----
 .../maven/plugins/source/stubs/Project001Stub.java | 126 ----------
 .../maven/plugins/source/stubs/Project003Stub.java | 108 ---------
 .../maven/plugins/source/stubs/Project005Stub.java |  94 -------
 .../maven/plugins/source/stubs/Project007Stub.java | 107 --------
 .../maven/plugins/source/stubs/Project009Stub.java | 109 ---------
 .../maven/plugins/source/stubs/Project010Stub.java | 108 ---------
 .../source/stubs/SourcePluginArtifactStub.java     | 134 ----------
 src/test/resources/unit/project-001/pom.xml        |   6 +-
 src/test/resources/unit/project-003/pom.xml        |   6 +-
 src/test/resources/unit/project-005/pom.xml        |   2 -
 src/test/resources/unit/project-007/pom.xml        |   4 +-
 src/test/resources/unit/project-009/pom.xml        |   4 +-
 src/test/resources/unit/project-010/pom.xml        |   6 +-
 31 files changed, 548 insertions(+), 1301 deletions(-)

diff --git a/.github/workflows/maven-verify.yml 
b/.github/workflows/maven-verify.yml
index 932827c..56062b5 100644
--- a/.github/workflows/maven-verify.yml
+++ b/.github/workflows/maven-verify.yml
@@ -25,3 +25,7 @@ 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" ]'
diff --git a/pom.xml b/pom.xml
index 2443c1f..5a3f894 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,12 +23,12 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>41</version>
+    <version>42</version>
     <relativePath />
   </parent>
 
   <artifactId>maven-source-plugin</artifactId>
-  <version>3.3.2-SNAPSHOT</version>
+  <version>4.0.0-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven Source Plugin</name>
@@ -77,17 +77,33 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <javaVersion>8</javaVersion>
-    <mavenVersion>3.2.5</mavenVersion>
+    <javaVersion>17</javaVersion>
+    <mavenVersion>4.0.0-beta-3</mavenVersion>
+
+    <guiceVersion>6.0.0</guiceVersion>
+    <junitVersion>5.10.2</junitVersion>
+    <mavenArchiverVersion>4.0.0-SNAPSHOT</mavenArchiverVersion>
+    <mavenPluginPluginVersion>4.0.0-SNAPSHOT</mavenPluginPluginVersion>
+    
<mavenPluginTestingVersion>4.0.0-alpha-3-SNAPSHOT</mavenPluginTestingVersion>
+    <mockitoVersion>5.12.0</mockitoVersion>
+    <plexusArchiverVersion>4.9.2</plexusArchiverVersion>
+    
<version.maven-plugin-tools>${mavenPluginPluginVersion}</version.maven-plugin-tools>
+    <version.maven-invoker-plugin>3.7.0</version.maven-invoker-plugin>
+
     
<project.build.outputTimestamp>2024-03-30T01:49:10Z</project.build.outputTimestamp>
   </properties>
 
   <dependencyManagement>
     <dependencies>
       <dependency>
-        <groupId>commons-io</groupId>
-        <artifactId>commons-io</artifactId>
-        <version>2.16.1</version>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>1.26.1</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>32.0.1-jre</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
@@ -95,68 +111,78 @@ under the License.
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-model</artifactId>
+      <artifactId>maven-api-core</artifactId>
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
+      <artifactId>maven-api-di</artifactId>
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
+      <artifactId>maven-api-model</artifactId>
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
+      <artifactId>maven-api-meta</artifactId>
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
 
-    <!-- dependencies to annotations -->
-    <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <scope>provided</scope>
-    </dependency>
-
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-archiver</artifactId>
-      <version>3.6.2</version>
+      <version>${mavenArchiverVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
-      <version>4.9.2</version>
+      <version>${plexusArchiverVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.5.1</version>
     </dependency>
 
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
-      <version>3.3.0</version>
+      <version>${mavenPluginTestingVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>${mavenVersion}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-compat</artifactId>
+      <artifactId>maven-api-impl</artifactId>
       <version>${mavenVersion}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.13.2</version>
+      <groupId>com.google.inject</groupId>
+      <artifactId>guice</artifactId>
+      <version>${guiceVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>${junitVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>${mockitoVersion}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/src/it/MSOURCES-121/verify.groovy 
b/src/it/MSOURCES-121/verify.groovy
index e58ef75..308a3c7 100644
--- a/src/it/MSOURCES-121/verify.groovy
+++ b/src/it/MSOURCES-121/verify.groovy
@@ -19,4 +19,5 @@
 
 File buildLog = new File( basedir, 'build.log' )
 
-assert buildLog.text =~ /\[ERROR\] Artifact 
org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT 
already attached to a file target.jar-no-fork-1.0-SNAPSHOT-sources.jar: attach 
to target.jar-no-fork-1.0-SNAPSHOT-secondary-sources.jar should be done with 
another classifier/
+var fs = File.separatorChar == '\\' ? "\\\\" : "/"
+assert buildLog.text =~ /\[ERROR\] Artifact 
org.apache.maven.its.sources:jar-no-fork:jar:sources:1.0-SNAPSHOT already 
attached to a file target${fs}jar-no-fork-1.0-SNAPSHOT-sources.jar: attach to 
target${fs}jar-no-fork-1.0-SNAPSHOT-secondary-sources.jar should be done with 
another classifier/
diff --git a/src/it/MSOURCES-140/invoker.properties 
b/src/it/MSOURCES-140/invoker.properties
index 54abe94..cfb882b 100644
--- a/src/it/MSOURCES-140/invoker.properties
+++ b/src/it/MSOURCES-140/invoker.properties
@@ -16,3 +16,6 @@
 # under the License.
 invoker.buildResult = success
 invoker.goals = package clean install
+
+# maven 4.0.0-beta-3 is broken because of 
https://github.com/apache/maven/pull/1587
+invoker.maven.version = 4.0.0-beta-4+
\ No newline at end of file
diff --git a/src/it/MSOURCES-140/verify.groovy 
b/src/it/MSOURCES-140/verify.groovy
index 8cc6491..e9b0fd2 100644
--- a/src/it/MSOURCES-140/verify.groovy
+++ b/src/it/MSOURCES-140/verify.groovy
@@ -19,4 +19,4 @@
 
 File buildLog = new File( basedir, 'build.log' )
 
-assert buildLog.text =~ /\[INFO\] Artifact 
org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT 
already attached to target.jar-no-fork-1.0-SNAPSHOT-sources.jar: ignoring same 
re-attach \(same artifact, same file\)/
+assert buildLog.text =~ /\[INFO\] Artifact 
org.apache.maven.its.sources:jar-no-fork:jar:sources:1.0-SNAPSHOT already 
attached to target" + File.separator + "jar-no-fork-1.0-SNAPSHOT-sources.jar: 
ignoring same re-attach \(same artifact, same file\)/
diff --git a/src/it/MSOURCES-62/pom.xml b/src/it/MSOURCES-62/pom.xml
index 582ea44..1a7f1b6 100644
--- a/src/it/MSOURCES-62/pom.xml
+++ b/src/it/MSOURCES-62/pom.xml
@@ -39,7 +39,6 @@ under the License.
               <phase>package</phase>
               <configuration>
                 <archive>
-                  <index>true</index>
                   <addMavenDescriptor>false</addMavenDescriptor>
                   <compress>true</compress>
                   <manifestEntries>
diff --git 
a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
index 284d2f1..d8f1747 100644
--- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
@@ -19,30 +19,32 @@
 package org.apache.maven.plugins.source;
 
 import java.io.File;
-import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.di.Inject;
+import org.apache.maven.api.model.Resource;
+import org.apache.maven.api.plugin.Log;
+import org.apache.maven.api.plugin.Mojo;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Parameter;
+import org.apache.maven.api.services.ArtifactManager;
+import org.apache.maven.api.services.ProjectManager;
 import org.apache.maven.archiver.MavenArchiveConfiguration;
 import org.apache.maven.archiver.MavenArchiver;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
-import org.codehaus.plexus.archiver.jar.ManifestException;
 import org.codehaus.plexus.archiver.util.DefaultFileSet;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -51,7 +53,7 @@ import org.codehaus.plexus.util.FileUtils;
  *
  * @since 2.0.3
  */
-public abstract class AbstractSourceJarMojo extends AbstractMojo {
+public abstract class AbstractSourceJarMojo implements Mojo {
     private static final String[] DEFAULT_INCLUDES = new String[] {"**/**"};
 
     private static final String[] DEFAULT_EXCLUDES = new String[] {};
@@ -63,7 +65,7 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter
-    private String[] includes;
+    protected String[] includes;
 
     /**
      * List of files to exclude. Specified as fileset patterns which are 
relative to the input directory whose contents
@@ -72,7 +74,7 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter
-    private String[] excludes;
+    protected String[] excludes;
 
     /**
      * Exclude commonly excluded files such as SCM configuration. These are 
defined in the plexus
@@ -81,19 +83,19 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter(property = "maven.source.useDefaultExcludes", defaultValue = 
"true")
-    private boolean useDefaultExcludes;
+    protected boolean useDefaultExcludes;
 
     /**
      * The Maven Project Object
      */
-    @Parameter(defaultValue = "${project}", readonly = true, required = true)
-    private MavenProject project;
+    @Inject
+    protected Project project;
 
     /**
      * The Jar archiver.
      */
-    @Component(role = Archiver.class, hint = "jar")
-    private JarArchiver jarArchiver;
+    @Inject
+    protected JarArchiver jarArchiver;
 
     /**
      * The archive configuration to use. See <a 
href="http://maven.apache.org/shared/maven-archiver/index.html";>Maven
@@ -105,7 +107,7 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter
-    private MavenArchiveConfiguration archive = new 
MavenArchiveConfiguration();
+    protected MavenArchiveConfiguration archive = new 
MavenArchiveConfiguration();
 
     /**
      * Path to the default MANIFEST file to use. It will be used if 
<code>useDefaultManifestFile</code> is set to
@@ -119,7 +121,7 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
             readonly = false,
             required = true)
     // CHECKSTYLE_ON: LineLength
-    private File defaultManifestFile;
+    protected Path defaultManifestFile;
 
     /**
      * Set this to <code>true</code> to enable the use of the 
<code>defaultManifestFile</code>. <br/>
@@ -127,16 +129,16 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter(property = "maven.source.useDefaultManifestFile", defaultValue 
= "false")
-    private boolean useDefaultManifestFile;
+    protected boolean useDefaultManifestFile;
 
     /**
-     * Specifies whether or not to attach the artifact to the project
+     * Specifies whether to attach the artifact to the project
      */
     @Parameter(property = "maven.source.attach", defaultValue = "true")
-    private boolean attach;
+    protected boolean attach;
 
     /**
-     * Specifies whether or not to exclude resources from the sources-jar. 
This can be convenient if your project
+     * Specifies whether to exclude resources from the sources-jar. This can 
be convenient if your project
      * includes large resources, such as images, and you don't want to include 
them in the sources-jar.
      *
      * @since 2.0.4
@@ -145,24 +147,18 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
     protected boolean excludeResources;
 
     /**
-     * Specifies whether or not to include the POM file in the sources-jar.
+     * Specifies whether to include the POM file in the sources-jar.
      *
      * @since 2.1
      */
     @Parameter(property = "maven.source.includePom", defaultValue = "false")
     protected boolean includePom;
 
-    /**
-     * Used for attaching the source jar to the project.
-     */
-    @Component
-    private MavenProjectHelper projectHelper;
-
     /**
      * The directory where the generated archive file will be put.
      */
     @Parameter(defaultValue = "${project.build.directory}")
-    protected File outputDirectory;
+    protected Path outputDirectory;
 
     /**
      * The filename to be used for the generated archive file. For the 
source:jar goal, "-sources" is appended to this
@@ -174,8 +170,8 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
     /**
      * Contains the full list of projects in the reactor.
      */
-    @Parameter(defaultValue = "${reactorProjects}", readonly = true)
-    protected List<MavenProject> reactorProjects;
+    @Parameter(defaultValue = "${session.projects}", readonly = true)
+    protected List<Project> reactorProjects;
 
     /**
      * Whether creating the archive should be forced. If set to true, the jar 
will always be created. If set to false,
@@ -184,7 +180,7 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.1
      */
     @Parameter(property = "maven.source.forceCreation", defaultValue = "false")
-    private boolean forceCreation;
+    protected boolean forceCreation;
 
     /**
      * A flag used to disable the source procedure. This is primarily intended 
for usage from the command line to
@@ -193,13 +189,13 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 2.2
      */
     @Parameter(property = "maven.source.skip", defaultValue = "false")
-    private boolean skipSource;
+    protected boolean skipSource;
 
     /**
      * The Maven session.
      */
-    @Parameter(defaultValue = "${session}", readonly = true, required = true)
-    private MavenSession session;
+    @Inject
+    protected Session session;
 
     /**
      * Timestamp for reproducible output archive entries, either formatted as 
ISO 8601
@@ -209,21 +205,38 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
      * @since 3.2.0
      */
     @Parameter(defaultValue = "${project.build.outputTimestamp}")
-    private String outputTimestamp;
+    protected String outputTimestamp;
+
+    @Inject
+    protected Log log;
+
+    /**
+     * Used for attaching the source jar to the project.
+     */
+    protected ProjectManager projectManager;
 
     // ----------------------------------------------------------------------
     // Public methods
     // ----------------------------------------------------------------------
 
+    public Log getLog() {
+        return log;
+    }
+
     /**
      * {@inheritDoc}
      */
-    public void execute() throws MojoExecutionException {
+    public void execute() throws MojoException {
         if (skipSource) {
             getLog().info("Skipping source per configuration.");
             return;
         }
 
+        projectManager = session.getService(ProjectManager.class);
+        doExecute();
+    }
+
+    protected void doExecute() {
         packageSources(project);
     }
 
@@ -237,48 +250,51 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
     protected abstract String getClassifier();
 
     /**
-     * @param p {@link MavenProject} not null
+     * @param p {@link Project} not null
      * @return the compile or test sources
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
-    protected abstract List<String> getSources(MavenProject p) throws 
MojoExecutionException;
+    protected abstract List<Path> getSources(Project p) throws MojoException;
 
     /**
-     * @param p {@link MavenProject} not null
+     * @param p {@link Project} not null
      * @return the compile or test resources
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
-    protected abstract List<Resource> getResources(MavenProject p) throws 
MojoExecutionException;
+    protected abstract List<Resource> getResources(Project p) throws 
MojoException;
 
     /**
-     * @param p {@link MavenProject}
-     * @throws MojoExecutionException in case of an error.
+     * @param p {@link Project}
+     * @throws MojoException in case of an error.
      */
-    protected void packageSources(MavenProject p) throws 
MojoExecutionException {
-        if (!"pom".equals(p.getPackaging())) {
+    protected void packageSources(Project p) throws MojoException {
+        String type = p.getPackaging().type().id();
+        if (!Type.POM.equals(type) && !Type.BOM.equals(type)) {
             packageSources(Collections.singletonList(p));
         }
     }
 
     /**
-     * @param theProjects {@link MavenProject}
-     * @throws MojoExecutionException in case of an error.
+     * @param theProjects {@link Project}
+     * @throws MojoException in case of an error.
      */
-    protected void packageSources(List<MavenProject> theProjects) throws 
MojoExecutionException {
-        if (project.getArtifact().getClassifier() != null) {
+    protected void packageSources(List<Project> theProjects) throws 
MojoException {
+        Artifact currentProjectArtifact = project.getMainArtifact().get();
+        if (!currentProjectArtifact.getClassifier().isEmpty()) {
             getLog().warn("NOT adding sources to artifacts with classifier as 
Maven only supports one classifier "
-                    + "per artifact. Current artifact [" + 
project.getArtifact().getId() + "] has a ["
-                    + project.getArtifact().getClassifier() + "] classifier.");
+                    + "per artifact. Current artifact [" + 
currentProjectArtifact.key() + "] has a ["
+                    + currentProjectArtifact.getClassifier() + "] 
classifier.");
 
             return;
         }
 
         MavenArchiver archiver = createArchiver();
 
-        for (MavenProject pItem : theProjects) {
-            MavenProject subProject = getProject(pItem);
+        for (Project pItem : theProjects) {
+            Project subProject = getProject(pItem);
 
-            if ("pom".equals(subProject.getPackaging())) {
+            String type = subProject.getPackaging().type().id();
+            if (Type.POM.equals(type) || Type.BOM.equals(type)) {
                 continue;
             }
 
@@ -287,46 +303,52 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
 
         if (archiver.getArchiver().getResources().hasNext() || forceCreation) {
 
-            if (useDefaultManifestFile && defaultManifestFile.exists() && 
archive.getManifestFile() == null) {
-                getLog().info("Adding existing MANIFEST to archive. Found 
under: " + defaultManifestFile.getPath());
+            if (useDefaultManifestFile && Files.exists(defaultManifestFile) && 
archive.getManifestFile() == null) {
+                getLog().info("Adding existing MANIFEST to archive. Found 
under: " + defaultManifestFile);
                 archive.setManifestFile(defaultManifestFile);
             }
 
-            File outputFile = new File(outputDirectory, finalName + "-" + 
getClassifier() + getExtension());
+            Path outputFile = outputDirectory.resolve(finalName + "-" + 
getClassifier() + getExtension());
 
             try {
-                archiver.setOutputFile(outputFile);
+                archiver.setOutputFile(outputFile.toFile());
                 archive.setForced(forceCreation);
 
                 getLog().debug("create archive " + outputFile);
                 archiver.createArchive(session, project, archive);
-            } catch (IOException | ArchiverException | 
DependencyResolutionRequiredException | ManifestException e) {
-                throw new MojoExecutionException("Error creating source 
archive: " + e.getMessage(), e);
+            } catch (ArchiverException e) {
+                throw new MojoException("Error creating source archive: " + 
e.getMessage(), e);
             }
 
             if (attach) {
+                Artifact artifact = session.createArtifact(
+                        project.getGroupId(),
+                        project.getArtifactId(),
+                        project.getVersion(),
+                        getClassifier(),
+                        null,
+                        getType());
                 boolean requiresAttach = true;
-                for (Artifact attachedArtifact : 
project.getAttachedArtifacts()) {
-                    Artifact previouslyAttachedArtifact =
-                            getPreviouslyAttached(attachedArtifact, project, 
getClassifier());
-                    if (previouslyAttachedArtifact != null) {
-                        File previouslyAttachedFile = 
previouslyAttachedArtifact.getFile();
-                        // trying to attache the same file/path or not?
-                        if (!outputFile.equals(previouslyAttachedFile)) {
-                            getLog().error("Artifact " + 
previouslyAttachedArtifact.getId()
-                                    + " already attached to a file " + 
relative(previouslyAttachedFile) + ": attach to "
+                for (Artifact attachedArtifact : 
projectManager.getAttachedArtifacts(project)) {
+                    if (Objects.equals(artifact.key(), 
attachedArtifact.key())) {
+                        Path attachedFile = 
session.getService(ArtifactManager.class)
+                                .getPath(attachedArtifact)
+                                .orElse(null);
+                        if (attachedFile != null && 
!outputFile.equals(attachedFile)) {
+                            getLog().error("Artifact " + attachedArtifact.key()
+                                    + " already attached to a file " + 
relative(attachedFile) + ": attach to "
                                     + relative(outputFile) + " should be done 
with another classifier");
-                            throw new MojoExecutionException("Presumably you 
have configured maven-source-plugin "
+                            throw new MojoException("Presumably you have 
configured maven-source-plugin "
                                     + "to execute twice in your build to 
different output files. "
                                     + "You have to configure a classifier for 
at least one of them.");
                         }
                         requiresAttach = false;
-                        getLog().info("Artifact " + 
previouslyAttachedArtifact.getId() + " already attached to "
+                        getLog().info("Artifact " + attachedArtifact.key() + " 
already attached to "
                                 + relative(outputFile) + ": ignoring same 
re-attach (same artifact, same file)");
                     }
                 }
                 if (requiresAttach) {
-                    projectHelper.attachArtifact(project, getType(), 
getClassifier(), outputFile);
+                    projectManager.attachArtifact(project, artifact, 
outputFile);
                 }
             } else {
                 getLog().info("NOT adding java-sources to attached artifacts 
list.");
@@ -336,50 +358,48 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
         }
     }
 
-    private String relative(File to) {
-        Path basedir = project.getBasedir().getAbsoluteFile().toPath();
-        return basedir.relativize(to.getAbsoluteFile().toPath()).toString();
+    private String relative(Path to) {
+        Path basedir = project.getBasedir().toAbsolutePath();
+        return basedir.relativize(to.toAbsolutePath()).toString();
     }
 
-    private Artifact getPreviouslyAttached(Artifact artifact, MavenProject 
checkProject, String classifier) {
-        return artifact.getType().equals(getType())
+    private Artifact getPreviouslyAttached(Artifact artifact, Project 
checkProject, String classifier) {
+        return artifact.getExtension().equals(getExtension())
                         && 
artifact.getGroupId().equals(checkProject.getGroupId())
                         && 
artifact.getArtifactId().equals(checkProject.getArtifactId())
-                        && 
artifact.getVersion().equals(checkProject.getVersion())
+                        && 
artifact.getVersion().toString().equals(checkProject.getVersion())
                         && Objects.equals(artifact.getClassifier(), classifier)
                 ? artifact
                 : null;
     }
 
     /**
-     * @param p {@link MavenProject}
+     * @param project {@link Project}
      * @param archiver {@link Archiver}
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
-    protected void archiveProjectContent(MavenProject p, Archiver archiver) 
throws MojoExecutionException {
+    protected void archiveProjectContent(Project project, Archiver archiver) 
throws MojoException {
         if (includePom) {
             try {
-                archiver.addFile(p.getFile(), p.getFile().getName());
+                File pom = project.getPomPath().toFile();
+                archiver.addFile(pom, pom.getName());
             } catch (ArchiverException e) {
-                throw new MojoExecutionException("Error adding POM file to 
target jar file.", e);
+                throw new MojoException("Error adding POM file to target jar 
file.", e);
             }
         }
 
-        for (String s : getSources(p)) {
-
-            File sourceDirectory = new File(s);
-
-            if (sourceDirectory.exists()) {
+        for (Path sourceDirectory : getSources(project)) {
+            if (Files.exists(sourceDirectory)) {
                 addDirectory(archiver, sourceDirectory, 
getCombinedIncludes(null), getCombinedExcludes(null));
             }
         }
 
         // MAPI: this should be taken from the resources plugin
-        for (Resource resource : getResources(p)) {
+        for (Resource resource : getResources(project)) {
 
-            File sourceDirectory = new File(resource.getDirectory());
+            Path sourceDirectory = Paths.get(resource.getDirectory());
 
-            if (!sourceDirectory.exists()) {
+            if (!Files.exists(sourceDirectory)) {
                 continue;
             }
 
@@ -405,9 +425,9 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
 
     /**
      * @return {@link MavenArchiver}
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
-    protected MavenArchiver createArchiver() throws MojoExecutionException {
+    protected MavenArchiver createArchiver() throws MojoException {
         MavenArchiver archiver = new MavenArchiver();
         archiver.setArchiver(jarArchiver);
         archiver.setCreatedBy("Maven Source Plugin", 
"org.apache.maven.plugins", "maven-source-plugin");
@@ -417,13 +437,14 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
         archiver.configureReproducibleBuild(outputTimestamp);
 
         if (project.getBuild() != null) {
-            List<Resource> resources = project.getBuild().getResources();
+            List<org.apache.maven.api.model.Resource> resources =
+                    project.getBuild().getResources();
 
-            for (Resource r : resources) {
+            for (org.apache.maven.api.model.Resource r : resources) {
                 if 
(r.getDirectory().endsWith("maven-shared-archive-resources")) {
                     addDirectory(
                             archiver.getArchiver(),
-                            new File(r.getDirectory()),
+                            Paths.get(r.getDirectory()),
                             getCombinedIncludes(null),
                             getCombinedExcludes(null));
                 }
@@ -435,38 +456,39 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
 
     /**
      * @param archiver {@link Archiver}
-     * @param sourceDirectory {@link File}
+     * @param sourceDirectory {@link Path}
      * @param pIncludes The list of includes.
      * @param pExcludes The list of excludes.
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
-    protected void addDirectory(Archiver archiver, File sourceDirectory, 
String[] pIncludes, String[] pExcludes)
-            throws MojoExecutionException {
+    protected void addDirectory(Archiver archiver, Path sourceDirectory, 
String[] pIncludes, String[] pExcludes)
+            throws MojoException {
         try {
             getLog().debug("add directory " + sourceDirectory + " to 
archiver");
-            
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory).includeExclude(pIncludes,
 pExcludes));
+            
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory.toFile()).includeExclude(pIncludes,
 pExcludes));
         } catch (ArchiverException e) {
-            throw new MojoExecutionException("Error adding directory to source 
archive.", e);
+            throw new MojoException("Error adding directory to source 
archive.", e);
         }
     }
 
     /**
      * @param archiver {@link Archiver}
-     * @param sourceDirectory {@link File}
+     * @param sourceDirectory {@link Path}
      * @param prefix The prefix.
      * @param pIncludes the includes.
      * @param pExcludes the excludes.
-     * @throws MojoExecutionException in case of an error.
+     * @throws MojoException in case of an error.
      */
     protected void addDirectory(
-            Archiver archiver, File sourceDirectory, String prefix, String[] 
pIncludes, String[] pExcludes)
-            throws MojoExecutionException {
+            Archiver archiver, Path sourceDirectory, String prefix, String[] 
pIncludes, String[] pExcludes)
+            throws MojoException {
         try {
             getLog().debug("add directory " + sourceDirectory + " to archiver 
with prefix " + prefix);
-            archiver.addFileSet(
-                    
DefaultFileSet.fileSet(sourceDirectory).prefixed(prefix).includeExclude(pIncludes,
 pExcludes));
+            
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory.toFile())
+                    .prefixed(prefix)
+                    .includeExclude(pIncludes, pExcludes));
         } catch (ArchiverException e) {
-            throw new MojoExecutionException("Error adding directory to source 
archive.", e);
+            throw new MojoException("Error adding directory to source 
archive.", e);
         }
     }
 
@@ -478,15 +500,11 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
     }
 
     /**
-     * @param p {@link MavenProject}
+     * @param p {@link Project}
      * @return The execution projet.
      */
-    protected MavenProject getProject(MavenProject p) {
-        if (p.getExecutionProject() != null) {
-            return p.getExecutionProject();
-        }
-
-        return p;
+    protected Project getProject(Project p) {
+        return projectManager.getExecutionProject(p).orElse(p);
     }
 
     /**
@@ -554,14 +572,14 @@ public abstract class AbstractSourceJarMojo extends 
AbstractMojo {
     /**
      * @return The current project.
      */
-    protected MavenProject getProject() {
+    protected Project getProject() {
         return project;
     }
 
     /**
-     * @param project {@link MavenProject}
+     * @param project {@link Project}
      */
-    protected void setProject(MavenProject project) {
+    protected void setProject(Project project) {
         this.project = project;
     }
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java
index 2186bad..329e0a1 100644
--- a/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java
@@ -18,25 +18,25 @@
  */
 package org.apache.maven.plugins.source;
 
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Execute;
+import org.apache.maven.api.plugin.annotations.Mojo;
 
 /**
  * Aggregate sources for all modules in an aggregator project.
  *
  * @since 2.0.3
  */
-@Mojo(name = "aggregate", defaultPhase = LifecyclePhase.PACKAGE, aggregator = 
true, threadSafe = true)
-@Execute(phase = LifecyclePhase.GENERATE_SOURCES)
+@Mojo(name = "aggregate", defaultPhase = "package", aggregator = true)
+@Execute(phase = "generate-sources")
 public class AggregatorSourceJarMojo extends SourceJarMojo {
     /**
      * {@inheritDoc}
      */
     @Override
-    public void execute() throws MojoExecutionException {
-        if ("pom".equals(getProject().getPackaging())) {
+    protected void doExecute() throws MojoException {
+        if (Type.POM.equals(getProject().getPackaging().type().id())) {
             packageSources(reactorProjects);
         }
     }
diff --git a/src/it/MSOURCES-140/verify.groovy 
b/src/main/java/org/apache/maven/plugins/source/Archivers.java
similarity index 67%
copy from src/it/MSOURCES-140/verify.groovy
copy to src/main/java/org/apache/maven/plugins/source/Archivers.java
index 8cc6491..a4a7f33 100644
--- a/src/it/MSOURCES-140/verify.groovy
+++ b/src/main/java/org/apache/maven/plugins/source/Archivers.java
@@ -16,7 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.maven.plugins.source;
 
-File buildLog = new File( basedir, 'build.log' )
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.di.Singleton;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
 
-assert buildLog.text =~ /\[INFO\] Artifact 
org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT 
already attached to target.jar-no-fork-1.0-SNAPSHOT-sources.jar: ignoring same 
re-attach \(same artifact, same file\)/
+@Named
+public class Archivers {
+
+    @Provides
+    @Singleton
+    @Named("jar")
+    static JarArchiver createJarArchiver() {
+        return new JarArchiver();
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java
index 10dac7e..c40772a 100644
--- a/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java
@@ -18,9 +18,8 @@
  */
 package org.apache.maven.plugins.source;
 
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Execute;
+import org.apache.maven.api.plugin.annotations.Mojo;
 
 /**
  * This plugin bundles all the sources into a jar archive.
@@ -28,8 +27,8 @@ import org.apache.maven.plugins.annotations.Mojo;
  * @author <a href="mailto:[email protected]";>Trygve Laugst&oslash;l</a>
  * @since 2.0.3
  */
-@Mojo(name = "jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true)
-@Execute(phase = LifecyclePhase.GENERATE_SOURCES)
+@Mojo(name = "jar", defaultPhase = "package")
+@Execute(phase = "generate-sources")
 public class SourceJarMojo extends SourceJarNoForkMojo {
     // no op
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java 
b/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java
index e621c74..8495998 100644
--- a/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java
@@ -18,14 +18,15 @@
  */
 package org.apache.maven.plugins.source;
 
+import java.nio.file.Path;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.ProjectScope;
+import org.apache.maven.api.model.Resource;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
 
 /**
  * This goal bundles all the sources into a jar archive. This goal functions 
the same as the jar goal but does not fork
@@ -34,7 +35,7 @@ import org.apache.maven.project.MavenProject;
  * @author pgier
  * @since 2.1
  */
-@Mojo(name = "jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe 
= true)
+@Mojo(name = "jar-no-fork", defaultPhase = "package")
 public class SourceJarNoForkMojo extends AbstractSourceJarMojo {
     /**
      * @since 2.2
@@ -45,19 +46,19 @@ public class SourceJarNoForkMojo extends 
AbstractSourceJarMojo {
     /**
      * {@inheritDoc}
      */
-    protected List<String> getSources(MavenProject p) {
-        return p.getCompileSourceRoots();
+    protected List<Path> getSources(Project p) {
+        return projectManager.getCompileSourceRoots(p, ProjectScope.MAIN);
     }
 
     /**
      * {@inheritDoc}
      */
-    protected List<Resource> getResources(MavenProject p) {
+    protected List<Resource> getResources(Project p) {
         if (excludeResources) {
             return Collections.emptyList();
         }
 
-        return p.getResources();
+        return projectManager.getResources(p, ProjectScope.MAIN);
     }
 
     /**
diff --git 
a/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java
index b04022d..eb42b83 100644
--- 
a/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java
@@ -18,17 +18,16 @@
  */
 package org.apache.maven.plugins.source;
 
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Execute;
+import org.apache.maven.api.plugin.annotations.Mojo;
 
 /**
  * This plugin bundles all the test sources into a jar archive.
  *
  * @since 2.2
  */
-@Mojo(name = "generated-test-jar", defaultPhase = LifecyclePhase.PACKAGE, 
threadSafe = true)
-@Execute(phase = LifecyclePhase.GENERATE_TEST_SOURCES)
+@Mojo(name = "generated-test-jar", defaultPhase = "package")
+@Execute(phase = "generate-test-sources")
 public class TestSourceGeneratedJarMojo extends TestSourceJarNoForkMojo {
     // no op
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java 
b/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java
index 5e4de06..dd281dd 100644
--- a/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java
@@ -18,17 +18,16 @@
  */
 package org.apache.maven.plugins.source;
 
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Execute;
+import org.apache.maven.api.plugin.annotations.Mojo;
 
 /**
  * This plugin bundles all the test sources into a jar archive.
  *
  * @since 2.0.3
  */
-@Mojo(name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = 
true)
-@Execute(phase = LifecyclePhase.GENERATE_SOURCES)
+@Mojo(name = "test-jar", defaultPhase = "package")
+@Execute(phase = "generate-sources")
 public class TestSourceJarMojo extends TestSourceJarNoForkMojo {
     // no op
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java 
b/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java
index f9126c6..7763e83 100644
--- a/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java
@@ -18,14 +18,15 @@
  */
 package org.apache.maven.plugins.source;
 
+import java.nio.file.Path;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.ProjectScope;
+import org.apache.maven.api.model.Resource;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
 
 /**
  * This goal bundles all the test sources into a jar archive.  This goal 
functions the same
@@ -34,7 +35,7 @@ import org.apache.maven.project.MavenProject;
  *
  * @since 2.1
  */
-@Mojo(name = "test-jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, 
threadSafe = true)
+@Mojo(name = "test-jar-no-fork", defaultPhase = "package")
 public class TestSourceJarNoForkMojo extends AbstractSourceJarMojo {
     /**
      * @since 2.2
@@ -45,19 +46,19 @@ public class TestSourceJarNoForkMojo extends 
AbstractSourceJarMojo {
     /**
      * {@inheritDoc}
      */
-    protected List<String> getSources(MavenProject p) {
-        return p.getTestCompileSourceRoots();
+    protected List<Path> getSources(Project p) {
+        return projectManager.getCompileSourceRoots(p, ProjectScope.TEST);
     }
 
     /**
      * {@inheritDoc}
      */
-    protected List<Resource> getResources(MavenProject p) {
+    protected List<Resource> getResources(Project p) {
         if (excludeResources) {
             return Collections.emptyList();
         }
 
-        return p.getTestResources();
+        return projectManager.getResources(p, ProjectScope.TEST);
     }
 
     /**
diff --git 
a/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java
 
b/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java
index 19d9e99..2605fd8 100644
--- 
a/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java
+++ 
b/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java
@@ -27,110 +27,27 @@ import java.util.TreeSet;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * @author Stephane Nicoll
  */
-public abstract class AbstractSourcePluginTestCase extends 
AbstractMojoTestCase {
+public abstract class AbstractSourcePluginTestCase {
 
     protected static final String FINAL_NAME_PREFIX = 
"maven-source-plugin-test-";
 
     protected static final String FINAL_NAME_SUFFIX = "-99.0";
 
-    protected abstract String getGoal();
-
-    /**
-     * Execute the source plugin for the specified project.
-     *
-     * @param projectName the name of the project
-     * @param classifier The classifier.
-     * @throws Exception if an error occurred
-     */
-    protected void executeMojo(final String projectName, String classifier) 
throws Exception {
-        File testPom = new File(getBasedir(), getTestDir(projectName) + 
"/pom.xml");
-        AbstractSourceJarMojo mojo = (AbstractSourceJarMojo) 
lookupMojo(getGoal(), testPom);
-
-        // Without the following line the tests will fail, cause the 
project.getFile() will result with null.
-        mojo.getProject().setFile(testPom);
-
-        setVariableValueToObject(mojo, "classifier", classifier);
-
-        mojo.execute();
-    }
-
-    /**
-     * Executes the specified projects and asserts the given artifacts.
-     *
-     * @param projectName             the project to test
-     * @param expectSourceArchive     if a source archive is expected
-     * @param expectTestSourceArchive if a test source archive is expected
-     * @param expectedSourceFiles     the expected files in the source 
archive, if any
-     * @param expectedTestSourceFiles the expected files in the test source 
archive, if any
-     * @param classifier              the classifier.
-     * @return the base directory of the project
-     * @throws Exception if any error occurs
-     */
-    protected File doTestProject(
-            final String projectName,
-            boolean expectSourceArchive,
-            boolean expectTestSourceArchive,
-            final String[] expectedSourceFiles,
-            final String[] expectedTestSourceFiles,
-            String classifier)
-            throws Exception {
-        executeMojo(projectName, classifier);
-        final File testTargetDir = getTestTargetDir(projectName);
-
-        if (expectSourceArchive) {
-            assertSourceArchive(testTargetDir, projectName);
-            assertJarContent(getSourceArchive(testTargetDir, projectName), 
expectedSourceFiles);
-        }
-
-        if (expectTestSourceArchive) {
-            assertTestSourceArchive(testTargetDir, projectName);
-            assertJarContent(getTestSourceArchive(testTargetDir, projectName), 
expectedTestSourceFiles);
-        }
-
-        return testTargetDir;
-    }
-
-    /**
-     * Executes the specified projects and asserts the given artifacts for a 
source archive.
-     *
-     * @param projectName         the project to test
-     * @param expectedSourceFiles the expected files in the source archive, if 
any
-     * @param classifier          the classifier.
-     * @return the base directory of the project
-     * @throws Exception if any error occurs
-     */
-    protected File doTestProjectWithSourceArchive(
-            final String projectName, final String[] expectedSourceFiles, 
String classifier) throws Exception {
-        return doTestProject(projectName, true, false, expectedSourceFiles, 
null, classifier);
-    }
-
-    /**
-     * Executes the specified projects and asserts the given artifacts for a 
test source archive.
-     *
-     * @param projectName             the project to test
-     * @param expectedTestSourceFiles the expected files in the test source 
archive, if any
-     * @param classifier              the classifier.
-     * @return the base directory of the project
-     * @throws Exception if any error occurs
-     */
-    protected File doTestProjectWithTestSourceArchive(
-            final String projectName, final String[] expectedTestSourceFiles, 
String classifier) throws Exception {
-        return doTestProject(projectName, false, true, null, 
expectedTestSourceFiles, classifier);
-    }
-
     protected void assertSourceArchive(final File testTargetDir, final String 
projectName) {
         final File expectedFile = getSourceArchive(testTargetDir, projectName);
-        assertTrue("Source archive does not exist[" + 
expectedFile.getAbsolutePath() + "]", expectedFile.exists());
+        assertTrue(expectedFile.exists(), "Source archive does not exist[" + 
expectedFile.getAbsolutePath() + "]");
     }
 
     protected void assertTestSourceArchive(final File testTargetDir, final 
String projectName) {
         final File expectedFile = getTestSourceArchive(testTargetDir, 
projectName);
-        assertTrue("Test source archive does not exist[" + 
expectedFile.getAbsolutePath() + "]", expectedFile.exists());
+        assertTrue(expectedFile.exists(), "Test source archive does not 
exist[" + expectedFile.getAbsolutePath() + "]");
     }
 
     protected File getSourceArchive(final File testTargetDir, final String 
projectName) {
@@ -149,20 +66,12 @@ public abstract class AbstractSourcePluginTestCase extends 
AbstractMojoTestCase
         return FINAL_NAME_PREFIX + projectName + FINAL_NAME_SUFFIX + 
"-test-sources";
     }
 
-    protected File getTestDir(String projectName) throws IOException {
-        File f = new File("target/test-classes/unit/" + projectName);
-        if (!new File(f, "pom.xml").exists()) {
-            throw new IllegalStateException("No pom file found in " + 
f.getPath());
-        }
-        return f;
-    }
-
     protected void assertJarContent(final File jarFile, final String[] 
expectedFiles) throws IOException {
         ZipFile jar = new ZipFile(jarFile);
         Enumeration<? extends ZipEntry> entries = jar.entries();
 
         if (expectedFiles.length == 0) {
-            assertFalse("Jar file should not contain any entry", 
entries.hasMoreElements());
+            assertFalse(entries.hasMoreElements(), "Jar file should not 
contain any entry");
         } else {
             assertTrue(entries.hasMoreElements());
 
@@ -171,16 +80,16 @@ public abstract class AbstractSourcePluginTestCase extends 
AbstractMojoTestCase
             while (entries.hasMoreElements()) {
                 ZipEntry entry = entries.nextElement();
 
-                assertTrue("Not expecting " + entry.getName() + " in " + 
jarFile, expected.remove(entry.getName()));
+                assertTrue(expected.remove(entry.getName()), "Not expecting " 
+ entry.getName() + " in " + jarFile);
             }
 
-            assertTrue("Missing entries " + expected.toString() + " in " + 
jarFile, expected.isEmpty());
+            assertTrue(expected.isEmpty(), "Missing entries " + expected + " 
in " + jarFile);
         }
 
         jar.close();
     }
 
     protected File getTestTargetDir(String projectName) {
-        return new File(getBasedir(), "target/test/unit/" + projectName + 
"/target");
+        return new File(getBasedir(), "target/test-classes/unit/" + 
projectName + "/target");
     }
 }
diff --git 
a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java 
b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java
index d585f2f..58e170e 100644
--- a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java
@@ -19,106 +19,181 @@
 package org.apache.maven.plugins.source;
 
 import java.io.File;
+import java.nio.file.Paths;
+import java.util.Collections;
+
+import org.apache.maven.api.Project;
+import org.apache.maven.api.ProjectScope;
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.Basedir;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoParameter;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.api.plugin.testing.stubs.SessionMock;
+import org.apache.maven.api.services.ProjectManager;
+import org.apache.maven.internal.impl.InternalSession;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 /**
  * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
  */
+@MojoTest
 public class SourceJarMojoTest extends AbstractSourcePluginTestCase {
-    protected String getGoal() {
-        return "jar";
-    }
 
-    private String[] addMavenDescriptor(String project, String[] 
listOfElements) {
+    private String[] addMavenDescriptor(String project, String... 
listOfElements) {
         final String METAINF = "META-INF/";
         final String MAVENSOURCE = "maven/source/maven-source-plugin-test-";
-        String[] result = new String[listOfElements.length + 5];
-        System.arraycopy(listOfElements, 0, result, 0, listOfElements.length);
-        result[listOfElements.length] = METAINF + "maven/";
-        result[listOfElements.length + 1] = METAINF + "maven/source/";
-        result[listOfElements.length + 2] = METAINF + MAVENSOURCE + project + 
"/";
-        result[listOfElements.length + 3] = METAINF + MAVENSOURCE + project + 
"/pom.properties";
-        result[listOfElements.length + 4] = METAINF + MAVENSOURCE + project + 
"/pom.xml";
+        int length = listOfElements.length;
+        String[] result = new String[length + 5];
+        System.arraycopy(listOfElements, 0, result, 0, length);
+        result[length] = METAINF + "maven/";
+        result[length + 1] = METAINF + "maven/source/";
+        result[length + 2] = METAINF + MAVENSOURCE + project + "/";
+        result[length + 3] = METAINF + MAVENSOURCE + project + 
"/pom.properties";
+        result[length + 4] = METAINF + MAVENSOURCE + project + "/pom.xml";
         return result;
     }
 
-    public void testDefaultConfiguration() throws Exception {
-        doTestProjectWithSourceArchive(
-                "project-001",
-                addMavenDescriptor("project-001", new String[] {
-                    "default-configuration.properties",
-                    "foo/project001/App.java",
-                    "foo/project001/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/"
-                }),
-                "sources");
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-001")
+    @MojoParameter(name = "classifier", value = "sources")
+    void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception 
{
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertSourceArchive(target, "project-001");
+        assertJarContent(
+                getSourceArchive(target, "project-001"),
+                addMavenDescriptor(
+                        "project-001",
+                        "default-configuration.properties",
+                        "foo/project001/App.java",
+                        "foo/project001/",
+                        "foo/",
+                        "META-INF/MANIFEST.MF",
+                        "META-INF/"));
     }
 
-    public void testExcludes() throws Exception {
-        doTestProjectWithSourceArchive(
-                "project-003",
-                addMavenDescriptor("project-003", new String[] {
-                    "default-configuration.properties",
-                    "foo/project003/App.java",
-                    "foo/project003/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/"
-                }),
-                "sources");
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-003")
+    public void testExcludes(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertSourceArchive(target, "project-003");
+        assertJarContent(
+                getSourceArchive(target, "project-003"),
+                addMavenDescriptor(
+                        "project-003",
+                        "default-configuration.properties",
+                        "foo/project003/App.java",
+                        "foo/project003/",
+                        "foo/",
+                        "META-INF/MANIFEST.MF",
+                        "META-INF/"));
     }
 
-    public void testNoSources() throws Exception {
-        executeMojo("project-005", "sources");
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-005")
+    public void testNoSources(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
+
         // Now make sure that no archive got created
         final File expectedFile = getTestTargetDir("project-005");
         assertFalse(
-                "Source archive should not have been created[" + 
expectedFile.getAbsolutePath() + "]",
-                expectedFile.exists());
+                expectedFile.exists(),
+                "Source archive should not have been created[" + 
expectedFile.getAbsolutePath() + "]");
     }
 
-    public void testIncludes() throws Exception {
-        doTestProjectWithSourceArchive(
-                "project-007",
-                addMavenDescriptor("project-007", new String[] {
-                    "templates/configuration-template.properties",
-                    "foo/project007/App.java",
-                    "templates/",
-                    "foo/project007/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/"
-                }),
-                "sources");
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-007")
+    public void testIncludes(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertSourceArchive(target, "project-007");
+        assertJarContent(
+                getSourceArchive(target, "project-007"),
+                addMavenDescriptor(
+                        "project-007",
+                        "templates/configuration-template.properties",
+                        "foo/project007/App.java",
+                        "templates/",
+                        "foo/project007/",
+                        "foo/",
+                        "META-INF/MANIFEST.MF",
+                        "META-INF/"));
     }
 
-    public void testIncludePom() throws Exception {
-        doTestProjectWithSourceArchive(
-                "project-009",
-                addMavenDescriptor("project-009", new String[] {
-                    "default-configuration.properties",
-                    "pom.xml",
-                    "foo/project009/App.java",
-                    "foo/project009/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/"
-                }),
-                "sources");
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-009")
+    public void testIncludePom(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertSourceArchive(target, "project-009");
+        assertJarContent(
+                getSourceArchive(target, "project-009"),
+                addMavenDescriptor(
+                        "project-009",
+                        "default-configuration.properties",
+                        "pom.xml",
+                        "foo/project009/App.java",
+                        "foo/project009/",
+                        "foo/",
+                        "META-INF/MANIFEST.MF",
+                        "META-INF/"));
+    }
+
+    @Test
+    @InjectMojo(goal = "jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-010")
+    public void 
testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) 
throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertSourceArchive(target, "project-010");
+        assertJarContent(
+                getSourceArchive(target, "project-010"),
+                addMavenDescriptor(
+                        "project-010",
+                        "default-configuration.properties",
+                        "foo/project010/App.java",
+                        "foo/project010/",
+                        "foo/",
+                        "META-INF/MANIFEST.MF",
+                        "META-INF/"));
     }
 
-    public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws 
Exception {
-        doTestProjectWithSourceArchive(
-                "project-010",
-                addMavenDescriptor("project-010", new String[] {
-                    "default-configuration.properties",
-                    "foo/project010/App.java",
-                    "foo/project010/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/"
-                }),
-                "sources");
+    @Provides
+    InternalSession createSession() {
+        InternalSession session = 
SessionMock.getMockSession("target/local-repo");
+        ProjectManager projectManager = mock(ProjectManager.class);
+        
when(session.getService(ProjectManager.class)).thenReturn(projectManager);
+        when(projectManager.getCompileSourceRoots(any(), 
eq(ProjectScope.MAIN))).thenAnswer(iom -> {
+            Project p = iom.getArgument(0, Project.class);
+            return Collections.singletonList(
+                    
Paths.get(getBasedir()).resolve(p.getModel().getBuild().getSourceDirectory()));
+        });
+        when(projectManager.getResources(any(), 
eq(ProjectScope.MAIN))).thenAnswer(iom -> {
+            Project p = iom.getArgument(0, Project.class);
+            return p.getBuild().getResources().stream()
+                    .map(r -> r.withDirectory(
+                            
Paths.get(getBasedir()).resolve(r.getDirectory()).toString()))
+                    .toList();
+        });
+        return session;
     }
 }
diff --git 
a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java 
b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java
index bcb7b34..e0bc5fe 100644
--- a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java
@@ -19,80 +19,137 @@
 package org.apache.maven.plugins.source;
 
 import java.io.File;
+import java.nio.file.Paths;
+import java.util.Collections;
+
+import org.apache.maven.api.Project;
+import org.apache.maven.api.ProjectScope;
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.Basedir;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoParameter;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.api.plugin.testing.stubs.SessionMock;
+import org.apache.maven.api.services.ProjectManager;
+import org.apache.maven.internal.impl.InternalSession;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 /**
  * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
  */
+@MojoTest
 public class TestSourceJarMojoTest extends AbstractSourcePluginTestCase {
 
-    protected String getGoal() {
-        return "test-jar";
-    }
+    @Test
+    @InjectMojo(goal = "test-jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-001")
+    @MojoParameter(name = "classifier", value = "test-sources")
+    public void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws 
Exception {
+        mojo.execute();
 
-    public void testDefaultConfiguration() throws Exception {
-        doTestProjectWithTestSourceArchive(
-                "project-001",
-                new String[] {
-                    "test-default-configuration.properties",
-                    "foo/project001/AppTest.java",
-                    "foo/project001/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/",
-                    "META-INF/maven/",
-                    "META-INF/maven/source/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-001/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml"
-                },
-                "test-sources");
+        File target = new File(getBasedir(), "target");
+        assertTestSourceArchive(target, "project-001");
+        assertJarContent(getTestSourceArchive(target, "project-001"), new 
String[] {
+            "test-default-configuration.properties",
+            "foo/project001/AppTest.java",
+            "foo/project001/",
+            "foo/",
+            "META-INF/MANIFEST.MF",
+            "META-INF/",
+            "META-INF/maven/",
+            "META-INF/maven/source/",
+            "META-INF/maven/source/maven-source-plugin-test-project-001/",
+            
"META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties",
+            
"META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml"
+        });
     }
 
-    public void testExcludes() throws Exception {
-        doTestProjectWithTestSourceArchive(
-                "project-003",
-                new String[] {
-                    "test-default-configuration.properties",
-                    "foo/project003/AppTest.java",
-                    "foo/project003/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/",
-                    "META-INF/maven/",
-                    "META-INF/maven/source/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-003/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml"
-                },
-                "test-sources");
+    @Test
+    @InjectMojo(goal = "test-jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-003")
+    @MojoParameter(name = "classifier", value = "test-sources")
+    public void testExcludes(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertTestSourceArchive(target, "project-003");
+        assertJarContent(getTestSourceArchive(target, "project-003"), new 
String[] {
+            "test-default-configuration.properties",
+            "foo/project003/AppTest.java",
+            "foo/project003/",
+            "foo/",
+            "META-INF/MANIFEST.MF",
+            "META-INF/",
+            "META-INF/maven/",
+            "META-INF/maven/source/",
+            "META-INF/maven/source/maven-source-plugin-test-project-003/",
+            
"META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties",
+            
"META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml"
+        });
     }
 
-    public void testNoSources() throws Exception {
-        executeMojo("project-005", "test-sources");
+    @Test
+    @InjectMojo(goal = "test-jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-005")
+    @MojoParameter(name = "classifier", value = "test-sources")
+    public void testNoSources(AbstractSourceJarMojo mojo) throws Exception {
+        mojo.execute();
 
         // Now make sure that no archive got created
         final File expectedFile = getTestTargetDir("project-005");
         assertFalse(
-                "Test source archive should not have been created[" + 
expectedFile.getAbsolutePath() + "]",
-                expectedFile.exists());
+                expectedFile.exists(),
+                "Test source archive should not have been created[" + 
expectedFile.getAbsolutePath() + "]");
+    }
+
+    @Test
+    @InjectMojo(goal = "test-jar")
+    @Basedir("${basedir}/target/test-classes/unit/project-010")
+    @MojoParameter(name = "classifier", value = "test-sources")
+    public void 
testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) 
throws Exception {
+        mojo.execute();
+
+        File target = new File(getBasedir(), "target");
+        assertTestSourceArchive(target, "project-010");
+        assertJarContent(getTestSourceArchive(target, "project-010"), new 
String[] {
+            "test-default-configuration.properties",
+            "foo/project010/AppTest.java",
+            "foo/project010/",
+            "foo/",
+            "META-INF/MANIFEST.MF",
+            "META-INF/",
+            "META-INF/maven/",
+            "META-INF/maven/source/",
+            "META-INF/maven/source/maven-source-plugin-test-project-010/",
+            
"META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml",
+            "META-INF/maven/source/maven-source-plugin-test-project-010/pom" + 
".properties"
+        });
     }
 
-    public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws 
Exception {
-        doTestProjectWithTestSourceArchive(
-                "project-010",
-                new String[] {
-                    "test-default-configuration.properties",
-                    "foo/project010/AppTest.java",
-                    "foo/project010/",
-                    "foo/",
-                    "META-INF/MANIFEST.MF",
-                    "META-INF/",
-                    "META-INF/maven/",
-                    "META-INF/maven/source/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-010/",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml",
-                    
"META-INF/maven/source/maven-source-plugin-test-project-010/pom" + ".properties"
-                },
-                "test-sources");
+    @Provides
+    InternalSession createSession() {
+        InternalSession session = 
SessionMock.getMockSession("target/local-repo");
+        ProjectManager projectManager = mock(ProjectManager.class);
+        
when(session.getService(ProjectManager.class)).thenReturn(projectManager);
+        when(projectManager.getCompileSourceRoots(any(), 
eq(ProjectScope.TEST))).thenAnswer(iom -> {
+            Project p = iom.getArgument(0, Project.class);
+            return Collections.singletonList(
+                    
Paths.get(getBasedir()).resolve(p.getModel().getBuild().getTestSourceDirectory()));
+        });
+        when(projectManager.getResources(any(), 
eq(ProjectScope.TEST))).thenAnswer(iom -> {
+            Project p = iom.getArgument(0, Project.class);
+            return p.getBuild().getTestResources().stream()
+                    .map(r -> r.withDirectory(
+                            
Paths.get(getBasedir()).resolve(r.getDirectory()).toString()))
+                    .toList();
+        });
+        return session;
     }
 }
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java
 
b/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java
deleted file mode 100755
index 506f23a..0000000
--- 
a/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-
-/**
- * @author pgier
- */
-public class DefaultArtifactHandlerStub extends DefaultArtifactHandler {
-    private String language;
-
-    public String getLanguage() {
-        if (language == null) {
-            language = "java";
-        }
-
-        return language;
-    }
-
-    public void setLanguage(String language) {
-        this.language = language;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java
deleted file mode 100644
index 773eeb9..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.xml.XmlStreamReader;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
- */
-public class Project001Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project001Stub() {
-        Model model;
-
-        try {
-            model = readModelFromFile(new File(getBasedir(), 
"target/test-classes/unit/project-001/pom.xml"));
-            setModel(model);
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-001/target");
-            setBuild(build);
-
-            String basedir = getBasedir().getAbsolutePath();
-            List<String> compileSourceRoots = new ArrayList<>();
-            compileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-001/src/main/java");
-            setCompileSourceRoots(compileSourceRoots);
-
-            List<String> testCompileSourceRoots = new ArrayList<>();
-            testCompileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-001/src/test/java");
-            setTestCompileSourceRoots(testCompileSourceRoots);
-
-            setResources(model.getBuild().getResources());
-            setTestResources(model.getBuild().getTestResources());
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return this.resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-
-    static Model readModelFromFile(File file) throws IOException, 
XmlPullParserException {
-        MavenXpp3Reader pomReader = new MavenXpp3Reader();
-        XmlStreamReader reader = null;
-        try {
-            reader = ReaderFactory.newXmlReader(file);
-            final Model model = pomReader.read(reader);
-            reader.close();
-            reader = null;
-            return model;
-        } finally {
-            IOUtil.close(reader);
-        }
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java
deleted file mode 100644
index c010351..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-
-import static 
org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
-
-/**
- * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
- */
-public class Project003Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project003Stub() {
-        Model model;
-
-        try {
-            model = readModelFromFile(new File(getBasedir(), 
"target/test-classes/unit/project-003/pom.xml"));
-            setModel(model);
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-003/target");
-            setBuild(build);
-
-            String basedir = getBasedir().getAbsolutePath();
-            List<String> compileSourceRoots = new ArrayList<>();
-            compileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-003/src/main/java");
-            setCompileSourceRoots(compileSourceRoots);
-
-            List<String> testCompileSourceRoots = new ArrayList<>();
-            testCompileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-003/src/test/java");
-            setTestCompileSourceRoots(testCompileSourceRoots);
-
-            setResources(model.getBuild().getResources());
-            setTestResources(model.getBuild().getTestResources());
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java
deleted file mode 100644
index ee00cf6..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-
-import static 
org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
-
-/**
- * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
- */
-public class Project005Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project005Stub() {
-        Model model;
-        try {
-            model = readModelFromFile(new File(getBasedir(), 
"target/test-classes/unit/project-005/pom.xml"));
-            setModel(model);
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-005/target");
-            setBuild(build);
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java
deleted file mode 100644
index 120cc5b..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-
-import static 
org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
-
-/**
- * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
- */
-public class Project007Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project007Stub() {
-        Model model;
-        try {
-            model = readModelFromFile(new File(getBasedir(), 
"target/test-classes/unit/project-007/pom.xml"));
-            setModel(model);
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-007/target");
-            setBuild(build);
-
-            String basedir = getBasedir().getAbsolutePath();
-            List<String> compileSourceRoots = new ArrayList<>();
-            compileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-007/src/main/java");
-            setCompileSourceRoots(compileSourceRoots);
-
-            List<String> testCompileSourceRoots = new ArrayList<>();
-            testCompileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-007/src/test/java");
-            setTestCompileSourceRoots(testCompileSourceRoots);
-
-            setResources(model.getBuild().getResources());
-            setTestResources(model.getBuild().getTestResources());
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java
deleted file mode 100644
index 3955a2e..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-
-import static 
org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
-
-/**
- * @author Dennis Lundberg
- */
-public class Project009Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project009Stub() {
-        Model model;
-
-        try {
-            final File pomFile = new File(getBasedir(), 
"target/test-classes/unit/project-009/pom.xml");
-            model = readModelFromFile(pomFile);
-            setModel(model);
-            setFile(pomFile);
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-009/target");
-            setBuild(build);
-
-            String basedir = getBasedir().getAbsolutePath();
-            List<String> compileSourceRoots = new ArrayList<>();
-            compileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-009/src/main/java");
-            setCompileSourceRoots(compileSourceRoots);
-
-            List<String> testCompileSourceRoots = new ArrayList<>();
-            testCompileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-009/src/test/java");
-            setTestCompileSourceRoots(testCompileSourceRoots);
-
-            setResources(model.getBuild().getResources());
-            setTestResources(model.getBuild().getTestResources());
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java 
b/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java
deleted file mode 100644
index 90a5a4a..0000000
--- a/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-
-import static 
org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
-
-public class Project010Stub extends MavenProjectStub {
-    private Build build;
-
-    private List<Resource> resources;
-
-    private List<Resource> testResources;
-
-    public Project010Stub() {
-        Model model;
-
-        try {
-            model = readModelFromFile(new File(getBasedir(), 
"target/test-classes/unit/project-010/pom.xml"));
-            setModel(model);
-
-            setFile(new File(getBasedir(), 
"target/test-classes/unit/project-010/pom.xml"));
-
-            setGroupId(model.getGroupId());
-            setArtifactId(model.getArtifactId());
-            setVersion(model.getVersion());
-            setName(model.getName());
-            setUrl(model.getUrl());
-            setPackaging(model.getPackaging());
-
-            Build build = new Build();
-            build.setFinalName(getArtifactId() + "-" + getVersion());
-            build.setDirectory(getBasedir() + 
"/target/test/unit/project-010/target");
-
-            setBuild(build);
-
-            String basedir = getBasedir().getAbsolutePath();
-            List<String> compileSourceRoots = new ArrayList<>();
-            compileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-010/src/main/java");
-            setCompileSourceRoots(compileSourceRoots);
-
-            List<String> testCompileSourceRoots = new ArrayList<>();
-            testCompileSourceRoots.add(basedir + 
"/target/test-classes/unit/project-010/src/test/java");
-            setTestCompileSourceRoots(testCompileSourceRoots);
-
-            setResources(model.getBuild().getResources());
-            setTestResources(model.getBuild().getTestResources());
-
-            SourcePluginArtifactStub artifact =
-                    new SourcePluginArtifactStub(getGroupId(), 
getArtifactId(), getVersion(), getPackaging(), null);
-            artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
-            artifact.setType("jar");
-            artifact.setBaseVersion("1.0-SNAPSHOT");
-            setArtifact(artifact);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public Build getBuild() {
-        return build;
-    }
-
-    public void setBuild(Build build) {
-        this.build = build;
-    }
-
-    public List<Resource> getResources() {
-        return resources;
-    }
-
-    public void setResources(List<Resource> resources) {
-        this.resources = resources;
-    }
-
-    public List<Resource> getTestResources() {
-        return testResources;
-    }
-
-    public void setTestResources(List<Resource> testResources) {
-        this.testResources = testResources;
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java
 
b/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java
deleted file mode 100644
index b758a17..0000000
--- 
a/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.plugins.source.stubs;
-
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.plugin.testing.stubs.ArtifactStub;
-
-/**
- * @author <a href="mailto:[email protected]";>Maria Odea Ching</a>
- */
-public class SourcePluginArtifactStub extends ArtifactStub {
-
-    private String groupId;
-
-    private String artifactId;
-
-    private String version;
-
-    private String type;
-
-    private String classifier;
-
-    private String baseVersion;
-
-    private VersionRange versionRange;
-
-    private ArtifactHandler handler;
-
-    public SourcePluginArtifactStub(String groupId, String artifactId, String 
version, String type, String classifier) {
-        this.groupId = groupId;
-        this.artifactId = artifactId;
-        this.version = version;
-        this.type = type;
-        this.classifier = classifier;
-        versionRange = VersionRange.createFromVersion(version);
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setArtifactId(String artifactId) {
-        this.artifactId = artifactId;
-    }
-
-    public String getArtifactId() {
-        return artifactId;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setType(String packaging) {
-        this.type = packaging;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setClassifier(String classifier) {
-        this.classifier = classifier;
-    }
-
-    public String getClassifier() {
-        return classifier;
-    }
-
-    public boolean hasClassifier() {
-        return classifier != null;
-    }
-
-    public String getId() {
-        String id = groupId + ":" + artifactId + ":" + type + ":";
-
-        if (hasClassifier()) {
-            id = id + getClassifier() + ":";
-        }
-
-        id = id + version;
-
-        return id;
-    }
-
-    public VersionRange getVersionRange() {
-        return versionRange;
-    }
-
-    public void setVersionRange(VersionRange versionRange) {
-        this.versionRange = versionRange;
-    }
-
-    public String getBaseVersion() {
-        return baseVersion;
-    }
-
-    public void setBaseVersion(String baseVersion) {
-        this.baseVersion = baseVersion;
-    }
-
-    public ArtifactHandler getArtifactHandler() {
-        return handler;
-    }
-
-    public void setArtifactHandler(ArtifactHandler handler) {
-        this.handler = handler;
-    }
-}
diff --git a/src/test/resources/unit/project-001/pom.xml 
b/src/test/resources/unit/project-001/pom.xml
index 3cc99fb..c726e61 100644
--- a/src/test/resources/unit/project-001/pom.xml
+++ b/src/test/resources/unit/project-001/pom.xml
@@ -36,12 +36,12 @@ under the License.
   <build>
     <resources>
       <resource>
-        
<directory>target/test-classes/unit/project-001/src/main/resources</directory>
+        <directory>src/main/resources</directory>
       </resource>
     </resources>
     <testResources>
       <testResource>
-        
<directory>target/test-classes/unit/project-001/src/test/resources</directory>
+        <directory>src/test/resources</directory>
       </testResource>
     </testResources>
     <plugins>
@@ -49,8 +49,6 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project001Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-001/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-001-99.0</finalName>
           <reactorProjects />
         </configuration>
diff --git a/src/test/resources/unit/project-003/pom.xml 
b/src/test/resources/unit/project-003/pom.xml
index 214f9c1..fe73a62 100644
--- a/src/test/resources/unit/project-003/pom.xml
+++ b/src/test/resources/unit/project-003/pom.xml
@@ -35,7 +35,7 @@ under the License.
   <build>
     <resources>
       <resource>
-        
<directory>target/test-classes/unit/project-003/src/main/resources</directory>
+        <directory>src/main/resources</directory>
         <excludes>
           <exclude>excluded-file.txt</exclude>
         </excludes>
@@ -43,7 +43,7 @@ under the License.
     </resources>
     <testResources>
       <testResource>
-        
<directory>target/test-classes/unit/project-003/src/test/resources</directory>
+        <directory>src/test/resources</directory>
         <excludes>
           <exclude>excluded-file.txt</exclude>
         </excludes>
@@ -54,8 +54,6 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project003Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-003/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-003-99.0</finalName>
           <reactorProjects />
         </configuration>
diff --git a/src/test/resources/unit/project-005/pom.xml 
b/src/test/resources/unit/project-005/pom.xml
index 695bb43..0a80fce 100644
--- a/src/test/resources/unit/project-005/pom.xml
+++ b/src/test/resources/unit/project-005/pom.xml
@@ -39,8 +39,6 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project005Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-005/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-005-99.0</finalName>
           <reactorProjects />
         </configuration>
diff --git a/src/test/resources/unit/project-007/pom.xml 
b/src/test/resources/unit/project-007/pom.xml
index 58f199e..ddb1311 100644
--- a/src/test/resources/unit/project-007/pom.xml
+++ b/src/test/resources/unit/project-007/pom.xml
@@ -35,7 +35,7 @@ under the License.
   <build>
     <resources>
       <resource>
-        
<directory>target/test-classes/unit/project-007/src/main/resources</directory>
+        <directory>src/main/resources</directory>
         <includes>
           <include>templates/**</include>
         </includes>
@@ -46,8 +46,6 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project007Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-007/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-007-99.0</finalName>
           <reactorProjects />
         </configuration>
diff --git a/src/test/resources/unit/project-009/pom.xml 
b/src/test/resources/unit/project-009/pom.xml
index bea8dcd..1e95f69 100644
--- a/src/test/resources/unit/project-009/pom.xml
+++ b/src/test/resources/unit/project-009/pom.xml
@@ -35,7 +35,7 @@ under the License.
   <build>
     <resources>
       <resource>
-        
<directory>target/test-classes/unit/project-009/src/main/resources</directory>
+        <directory>src/main/resources</directory>
       </resource>
     </resources>
     <plugins>
@@ -44,8 +44,6 @@ under the License.
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
           <includePom>true</includePom>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project009Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-009/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-009-99.0</finalName>
           <reactorProjects />
         </configuration>
diff --git a/src/test/resources/unit/project-010/pom.xml 
b/src/test/resources/unit/project-010/pom.xml
index 819d6b8..d984dc9 100644
--- a/src/test/resources/unit/project-010/pom.xml
+++ b/src/test/resources/unit/project-010/pom.xml
@@ -36,12 +36,12 @@ under the License.
   <build>
     <resources>
       <resource>
-        
<directory>target/test-classes/unit/project-010/src/main/resources</directory>
+        <directory>src/main/resources</directory>
       </resource>
     </resources>
     <testResources>
       <testResource>
-        
<directory>target/test-classes/unit/project-010/src/test/resources</directory>
+        <directory>src/test/resources</directory>
       </testResource>
     </testResources>
     <plugins>
@@ -49,8 +49,6 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <configuration>
-          <project 
implementation="org.apache.maven.plugins.source.stubs.Project010Stub"/>
-          
<outputDirectory>${basedir}/target/test/unit/project-010/target</outputDirectory>
           <finalName>maven-source-plugin-test-project-010-99.0</finalName>
           <reactorProjects />
           <archive>

Reply via email to