Upgrade to maven 3.x and avoid using deprecated API (#4)

diff --git a/pom.xml b/pom.xml
index 6ea2b2b..7a35ef2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
   </description>
 
   <prerequisites>
-    <maven>2.2.1</maven>
+    <maven>${mavenVersion}</maven>
   </prerequisites>
 
   <scm>
@@ -68,7 +68,7 @@
   </distributionManagement>
 
   <properties>
-    <mavenVersion>2.2.1</mavenVersion>
+    <mavenVersion>3.2.5</mavenVersion>
     <javaVersion>7</javaVersion>
     <mavenFilteringVersion>3.1.1</mavenFilteringVersion>
     <sitePluginVersion>3.3</sitePluginVersion>
@@ -79,11 +79,6 @@
     <!-- maven core -->
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
-      <version>${mavenVersion}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
@@ -99,12 +94,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>${mavenVersion}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-settings</artifactId>
+      <artifactId>maven-artifact</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
 
@@ -118,17 +108,17 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-archiver</artifactId>
-      <version>3.5.0</version>
+      <version>3.5.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-artifact-resolver</artifactId>
-      <version>1.0</version>
+      <artifactId>maven-artifact-transfer</artifactId>
+      <version>0.13.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-common-artifact-filters</artifactId>
-      <version>1.4</version>
+      <version>3.2.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
@@ -140,17 +130,7 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-resources</artifactId>
-      <version>1.0.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-interpolation</artifactId>
-      <version>1.25</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>3.1.0</version>
+      <version>1.1.0</version>
     </dependency>
 
     <!-- other -->
@@ -175,19 +155,25 @@
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
-      <version>1.3</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.wagon</groupId>
-      <artifactId>wagon-provider-api</artifactId>
-      <version>2.2</version>
+      <version>3.1.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-verifier</artifactId>
-      <version>1.5</version>
+      <version>1.7.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-compat</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.7.32</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java b/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java
new file mode 100644
index 0000000..31000ae
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ModelInheritanceAssembler.java
@@ -0,0 +1,746 @@
+package org.apache.maven.plugin.resources.remote;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.DeploymentRepository;
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Extension;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.PluginManagement;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.model.ReportSet;
+import org.apache.maven.model.Reporting;
+import org.apache.maven.model.Resource;
+import org.apache.maven.model.Scm;
+import org.apache.maven.model.Site;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/**
+ * DefaultModelInheritanceAssembler
+ */
+public class ModelInheritanceAssembler
+{
+    // TODO Remove this!
+    public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance )
+    {
+        // The build has been set but we want to step in here and fill in
+        // values that have not been set by the child.
+
+        if ( childBuild.getSourceDirectory() == null )
+        {
+            childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
+        }
+
+        if ( childBuild.getScriptSourceDirectory() == null )
+        {
+            childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
+        }
+
+        if ( childBuild.getTestSourceDirectory() == null )
+        {
+            childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
+        }
+
+        if ( childBuild.getOutputDirectory() == null )
+        {
+            childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
+        }
+
+        if ( childBuild.getTestOutputDirectory() == null )
+        {
+            childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
+        }
+
+        // Extensions are accumulated
+        mergeExtensionLists( childBuild, parentBuild );
+
+        if ( childBuild.getDirectory() == null )
+        {
+            childBuild.setDirectory( parentBuild.getDirectory() );
+        }
+
+        if ( childBuild.getDefaultGoal() == null )
+        {
+            childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
+        }
+
+        if ( childBuild.getFinalName() == null )
+        {
+            childBuild.setFinalName( parentBuild.getFinalName() );
+        }
+
+        ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
+
+        List<Resource> resources = childBuild.getResources();
+        if ( ( resources == null ) || resources.isEmpty() )
+        {
+            childBuild.setResources( parentBuild.getResources() );
+        }
+
+        resources = childBuild.getTestResources();
+        if ( ( resources == null ) || resources.isEmpty() )
+        {
+            childBuild.setTestResources( parentBuild.getTestResources() );
+        }
+
+        // Plugins are aggregated if Plugin.inherit != false
+        ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance );
+
+        // Plugin management :: aggregate
+        PluginManagement dominantPM = childBuild.getPluginManagement();
+        PluginManagement recessivePM = parentBuild.getPluginManagement();
+
+        if ( ( dominantPM == null ) && ( recessivePM != null ) )
+        {
+            // FIXME: Filter out the inherited == false stuff!
+            childBuild.setPluginManagement( recessivePM );
+        }
+        else
+        {
+            ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
+        }
+    }
+
+    private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
+    {
+        if ( parent.getScm() != null )
+        {
+            Scm parentScm = parent.getScm();
+
+            Scm childScm = child.getScm();
+
+            if ( childScm == null )
+            {
+                childScm = new Scm();
+
+                child.setScm( childScm );
+            }
+
+            if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
+            {
+                childScm.setConnection(
+                    appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+            }
+
+            if ( StringUtils.isEmpty( childScm.getDeveloperConnection() )
+                && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
+            {
+                childScm
+                    .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(),
+                                                         childPathAdjustment, appendPaths ) );
+            }
+
+            if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
+            {
+                childScm.setUrl(
+                    appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+            }
+        }
+    }
+
+    public void copyModel( Model dest, Model source )
+    {
+        assembleModelInheritance( dest, source, null, false );
+    }
+
+    public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment )
+    {
+        assembleModelInheritance( child, parent, childPathAdjustment, true );
+    }
+
+    public void assembleModelInheritance( Model child, Model parent )
+    {
+        assembleModelInheritance( child, parent, null, true );
+    }
+
+    private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
+    {
+        // cannot inherit from null parent.
+        if ( parent == null )
+        {
+            return;
+        }
+
+        // Group id
+        if ( child.getGroupId() == null )
+        {
+            child.setGroupId( parent.getGroupId() );
+        }
+
+        // version
+        if ( child.getVersion() == null )
+        {
+            // The parent version may have resolved to something different, so we take what we asked for...
+            // instead of - child.setVersion( parent.getVersion() );
+
+            if ( child.getParent() != null )
+            {
+                child.setVersion( child.getParent().getVersion() );
+            }
+        }
+
+        // inceptionYear
+        if ( child.getInceptionYear() == null )
+        {
+            child.setInceptionYear( parent.getInceptionYear() );
+        }
+
+        // url
+        if ( child.getUrl() == null )
+        {
+            if ( parent.getUrl() != null )
+            {
+                child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+            }
+            else
+            {
+                child.setUrl( parent.getUrl() );
+            }
+        }
+
+        assembleDistributionInheritance( child, parent, childPathAdjustment, appendPaths );
+
+        // issueManagement
+        if ( child.getIssueManagement() == null )
+        {
+            child.setIssueManagement( parent.getIssueManagement() );
+        }
+
+        // description
+        if ( child.getDescription() == null )
+        {
+            child.setDescription( parent.getDescription() );
+        }
+
+        // Organization
+        if ( child.getOrganization() == null )
+        {
+            child.setOrganization( parent.getOrganization() );
+        }
+
+        // Scm
+        assembleScmInheritance( child, parent, childPathAdjustment, appendPaths );
+
+        // ciManagement
+        if ( child.getCiManagement() == null )
+        {
+            child.setCiManagement( parent.getCiManagement() );
+        }
+
+        // developers
+        if ( child.getDevelopers().size() == 0 )
+        {
+            child.setDevelopers( parent.getDevelopers() );
+        }
+
+        // licenses
+        if ( child.getLicenses().size() == 0 )
+        {
+            child.setLicenses( parent.getLicenses() );
+        }
+
+        // developers
+        if ( child.getContributors().size() == 0 )
+        {
+            child.setContributors( parent.getContributors() );
+        }
+
+        // mailingLists
+        if ( child.getMailingLists().size() == 0 )
+        {
+            child.setMailingLists( parent.getMailingLists() );
+        }
+
+        // Build
+        assembleBuildInheritance( child, parent );
+
+        assembleDependencyInheritance( child, parent );
+
+        child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) );
+//        child.setPluginRepositories(
+//            ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) );
+
+        assembleReportingInheritance( child, parent );
+
+        assembleDependencyManagementInheritance( child, parent );
+
+        Properties props = new Properties();
+        props.putAll( parent.getProperties() );
+        props.putAll( child.getProperties() );
+
+        child.setProperties( props );
+    }
+
+    // TODO Remove this!
+    private void assembleDependencyManagementInheritance( Model child, Model parent )
+    {
+        DependencyManagement parentDepMgmt = parent.getDependencyManagement();
+
+        DependencyManagement childDepMgmt = child.getDependencyManagement();
+
+        if ( parentDepMgmt != null )
+        {
+            if ( childDepMgmt == null )
+            {
+                child.setDependencyManagement( parentDepMgmt );
+            }
+            else
+            {
+                List<Dependency> childDeps = childDepMgmt.getDependencies();
+
+                Map<String, Dependency> mappedChildDeps = new TreeMap<>();
+                for ( Dependency dep : childDeps )
+                {
+                    mappedChildDeps.put( dep.getManagementKey(), dep );
+                }
+
+                for ( Dependency dep : parentDepMgmt.getDependencies() )
+                {
+                    if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
+                    {
+                        childDepMgmt.addDependency( dep );
+                    }
+                }
+            }
+        }
+    }
+
+    private void assembleReportingInheritance( Model child, Model parent )
+    {
+        // Reports :: aggregate
+        Reporting childReporting = child.getReporting();
+        Reporting parentReporting = parent.getReporting();
+
+        if ( parentReporting != null )
+        {
+            if ( childReporting == null )
+            {
+                childReporting = new Reporting();
+                child.setReporting( childReporting );
+            }
+
+            childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() );
+
+            if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) )
+            {
+                childReporting.setOutputDirectory( parentReporting.getOutputDirectory() );
+            }
+
+            mergeReportPluginLists( childReporting, parentReporting, true );
+        }
+    }
+
+    private static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
+    {
+        if ( ( child == null ) || ( parent == null ) )
+        {
+            // nothing to do.
+            return;
+        }
+
+        List<ReportPlugin> parentPlugins = parent.getPlugins();
+
+        if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
+        {
+            Map<String, ReportPlugin> assembledPlugins = new TreeMap<>();
+
+            Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap();
+
+            for ( ReportPlugin parentPlugin : parentPlugins )
+            {
+                String parentInherited = parentPlugin.getInherited();
+
+                if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.parseBoolean( parentInherited ) )
+                {
+
+                    ReportPlugin assembledPlugin = parentPlugin;
+
+                    ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() );
+
+                    if ( childPlugin != null )
+                    {
+                        assembledPlugin = childPlugin;
+
+                        mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
+                    }
+
+                    if ( handleAsInheritance && ( parentInherited == null ) )
+                    {
+                        assembledPlugin.unsetInheritanceApplied();
+                    }
+
+                    assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
+                }
+            }
+
+            for ( ReportPlugin childPlugin : childPlugins.values() )
+            {
+                if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
+                {
+                    assembledPlugins.put( childPlugin.getKey(), childPlugin );
+                }
+            }
+
+            child.setPlugins( new ArrayList<>( assembledPlugins.values() ) );
+
+            child.flushReportPluginMap();
+        }
+    }
+
+    private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
+    {
+        List<String> parentReports = parent.getReports();
+        List<String> childReports = child.getReports();
+
+        List<String> reports = new ArrayList<>();
+
+        if ( ( childReports != null ) && !childReports.isEmpty() )
+        {
+            reports.addAll( childReports );
+        }
+
+        if ( parentReports != null )
+        {
+            for ( String report : parentReports )
+            {
+                if ( !reports.contains( report ) )
+                {
+                    reports.add( report );
+                }
+            }
+        }
+
+        child.setReports( reports );
+
+        Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
+        Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
+
+        childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+
+        child.setConfiguration( childConfiguration );
+    }
+
+
+    public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
+                                                     boolean handleAsInheritance )
+    {
+        if ( ( child == null ) || ( parent == null ) )
+        {
+            // nothing to do.
+            return;
+        }
+
+        if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
+        {
+            child.setVersion( parent.getVersion() );
+        }
+
+        // from here to the end of the method is dealing with merging of the <executions/> section.
+        String parentInherited = parent.getInherited();
+
+        boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited );
+
+        List<ReportSet> parentReportSets = parent.getReportSets();
+
+        if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
+        {
+            Map<String, ReportSet> assembledReportSets = new TreeMap<>();
+
+            Map<String, ReportSet> childReportSets = child.getReportSetsAsMap();
+
+            for ( Object parentReportSet1 : parentReportSets )
+            {
+                ReportSet parentReportSet = (ReportSet) parentReportSet1;
+
+                if ( !handleAsInheritance || parentIsInherited )
+                {
+                    ReportSet assembledReportSet = parentReportSet;
+
+                    ReportSet childReportSet = childReportSets.get( parentReportSet.getId() );
+
+                    if ( childReportSet != null )
+                    {
+                        mergeReportSetDefinitions( childReportSet, parentReportSet );
+
+                        assembledReportSet = childReportSet;
+                    }
+                    else if ( handleAsInheritance && ( parentInherited == null ) )
+                    {
+                        parentReportSet.unsetInheritanceApplied();
+                    }
+
+                    assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
+                }
+            }
+
+            for ( Map.Entry<String, ReportSet> entry : childReportSets.entrySet() )
+            {
+                String id = entry.getKey();
+
+                if ( !assembledReportSets.containsKey( id ) )
+                {
+                    assembledReportSets.put( id, entry.getValue() );
+                }
+            }
+
+            child.setReportSets( new ArrayList<>( assembledReportSets.values() ) );
+
+            child.flushReportSetMap();
+        }
+
+    }
+
+    // TODO Remove this!
+    private void assembleDependencyInheritance( Model child, Model parent )
+    {
+        Map<String, Dependency> depsMap = new LinkedHashMap<>();
+
+        List<Dependency> deps = parent.getDependencies();
+
+        if ( deps != null )
+        {
+            for ( Dependency dependency : deps )
+            {
+                depsMap.put( dependency.getManagementKey(), dependency );
+            }
+        }
+
+        deps = child.getDependencies();
+
+        if ( deps != null )
+        {
+            for ( Dependency dependency : deps )
+            {
+                depsMap.put( dependency.getManagementKey(), dependency );
+            }
+        }
+
+        child.setDependencies( new ArrayList<>( depsMap.values() ) );
+    }
+
+    private void assembleBuildInheritance( Model child, Model parent )
+    {
+        Build childBuild = child.getBuild();
+        Build parentBuild = parent.getBuild();
+
+        if ( parentBuild != null )
+        {
+            if ( childBuild == null )
+            {
+                childBuild = new Build();
+                child.setBuild( childBuild );
+            }
+
+            assembleBuildInheritance( childBuild, parentBuild, true );
+        }
+    }
+
+    private void assembleDistributionInheritance( Model child, Model parent, String childPathAdjustment,
+                                                  boolean appendPaths )
+    {
+        if ( parent.getDistributionManagement() != null )
+        {
+            DistributionManagement parentDistMgmt = parent.getDistributionManagement();
+
+            DistributionManagement childDistMgmt = child.getDistributionManagement();
+
+            if ( childDistMgmt == null )
+            {
+                childDistMgmt = new DistributionManagement();
+
+                child.setDistributionManagement( childDistMgmt );
+            }
+
+            if ( childDistMgmt.getSite() == null )
+            {
+                if ( parentDistMgmt.getSite() != null )
+                {
+                    Site site = new Site();
+
+                    childDistMgmt.setSite( site );
+
+                    site.setId( parentDistMgmt.getSite().getId() );
+
+                    site.setName( parentDistMgmt.getSite().getName() );
+
+                    site.setUrl( parentDistMgmt.getSite().getUrl() );
+
+                    if ( site.getUrl() != null )
+                    {
+                        site.setUrl(
+                            appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
+                    }
+                }
+            }
+
+            if ( childDistMgmt.getRepository() == null )
+            {
+                if ( parentDistMgmt.getRepository() != null )
+                {
+                    DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getRepository() );
+                    childDistMgmt.setRepository( repository );
+                }
+            }
+
+            if ( childDistMgmt.getSnapshotRepository() == null )
+            {
+                if ( parentDistMgmt.getSnapshotRepository() != null )
+                {
+                    DeploymentRepository repository =
+                        copyDistributionRepository( parentDistMgmt.getSnapshotRepository() );
+                    childDistMgmt.setSnapshotRepository( repository );
+                }
+            }
+
+            if ( StringUtils.isEmpty( childDistMgmt.getDownloadUrl() ) )
+            {
+                childDistMgmt.setDownloadUrl( parentDistMgmt.getDownloadUrl() );
+            }
+
+            // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality.
+            // NOTE: We SHOULD NOT be inheriting relocation, since this relates to a single POM
+        }
+    }
+
+    private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository )
+    {
+        DeploymentRepository repository = new DeploymentRepository();
+
+        repository.setId( parentRepository.getId() );
+
+        repository.setName( parentRepository.getName() );
+
+        repository.setUrl( parentRepository.getUrl() );
+
+        repository.setLayout( parentRepository.getLayout() );
+
+        repository.setUniqueVersion( parentRepository.isUniqueVersion() );
+
+        return repository;
+    }
+
+    // TODO This should eventually be migrated to DefaultPathTranslator.
+    protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths )
+    {
+        String uncleanPath = parentPath;
+
+        if ( appendPaths )
+        {
+            if ( pathAdjustment != null )
+            {
+                uncleanPath += "/" + pathAdjustment;
+            }
+
+            if ( childPath != null )
+            {
+                uncleanPath += "/" + childPath;
+            }
+        }
+
+        String cleanedPath = "";
+
+        int protocolIdx = uncleanPath.indexOf( "://" );
+
+        if ( protocolIdx > -1 )
+        {
+            cleanedPath = uncleanPath.substring( 0, protocolIdx + 3 );
+            uncleanPath = uncleanPath.substring( protocolIdx + 3 );
+        }
+
+        if ( uncleanPath.startsWith( "/" ) )
+        {
+            cleanedPath += "/";
+        }
+
+        return cleanedPath + resolvePath( uncleanPath );
+    }
+
+    // TODO Move this to plexus-utils' PathTool.
+    private static String resolvePath( String uncleanPath )
+    {
+        LinkedList<String> pathElements = new LinkedList<>();
+
+        StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" );
+
+        while ( tokenizer.hasMoreTokens() )
+        {
+            String token = tokenizer.nextToken();
+
+            switch ( token )
+            {
+                case "":
+                    // Empty path entry ("...//.."), remove.
+                    break;
+                case "..":
+                    if ( pathElements.isEmpty() )
+                    {
+                        // FIXME: somehow report to the user
+                        // that there are too many '..' elements.
+                        // For now, ignore the extra '..'.
+                    }
+                    else
+                    {
+                        pathElements.removeLast();
+                    }
+                    break;
+                default:
+                    pathElements.addLast( token );
+                    break;
+            }
+        }
+
+        StringBuilder cleanedPath = new StringBuilder();
+
+        while ( !pathElements.isEmpty() )
+        {
+            cleanedPath.append( pathElements.removeFirst() );
+            if ( !pathElements.isEmpty() )
+            {
+                cleanedPath.append( '/' );
+            }
+        }
+
+        return cleanedPath.toString();
+    }
+
+    private static void mergeExtensionLists( Build childBuild, Build parentBuild )
+    {
+        for ( Extension e : parentBuild.getExtensions() )
+        {
+            if ( !childBuild.getExtensions().contains( e ) )
+            {
+                childBuild.addExtension( e );
+            }
+        }
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java b/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java
new file mode 100644
index 0000000..cc0570a
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java
@@ -0,0 +1,363 @@
+package org.apache.maven.plugin.resources.remote;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginContainer;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.model.Repository;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/** HELPER CLASS */
+public final class ModelUtils
+{
+
+    /**
+     * This should be the resulting ordering of plugins after merging:
+     * <p>
+     * Given:
+     * <pre>
+     * parent: X -&gt; A -&gt; B -&gt; D -&gt; E
+     * child: Y -&gt; A -&gt; C -&gt; D -&gt; F
+     * </pre>
+     * Result:
+     * <pre>
+     * X -&gt; Y -&gt; A -&gt; B -&gt; C -&gt; D -&gt; E -&gt; F
+     * </pre>
+     */
+    public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
+                                         boolean handleAsInheritance )
+    {
+        if ( ( childContainer == null ) || ( parentContainer == null ) )
+        {
+            // nothing to do.
+            return;
+        }
+
+        List<Plugin> parentPlugins = parentContainer.getPlugins();
+
+        if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
+        {
+            parentPlugins = new ArrayList<>( parentPlugins );
+
+            // If we're processing this merge as an inheritance, we have to build up a list of
+            // plugins that were considered for inheritance.
+            if ( handleAsInheritance )
+            {
+                for ( Iterator<Plugin> it = parentPlugins.iterator(); it.hasNext(); )
+                {
+                    Plugin plugin = it.next();
+
+                    String inherited = plugin.getInherited();
+
+                    if ( ( inherited != null ) && !Boolean.parseBoolean( inherited ) )
+                    {
+                        it.remove();
+                    }
+                }
+            }
+
+            List<Plugin> assembledPlugins = new ArrayList<>();
+
+            Map<String, Plugin> childPlugins = childContainer.getPluginsAsMap();
+
+            for ( Plugin parentPlugin : parentPlugins )
+            {
+                String parentInherited = parentPlugin.getInherited();
+
+                // only merge plugin definition from the parent if at least one
+                // of these is true:
+                // 1. we're not processing the plugins in an inheritance-based merge
+                // 2. the parent's <inherited/> flag is not set
+                // 3. the parent's <inherited/> flag is set to true
+                if ( !handleAsInheritance || ( parentInherited == null )
+                    || Boolean.parseBoolean( parentInherited ) )
+                {
+                    Plugin childPlugin = childPlugins.get( parentPlugin.getKey() );
+
+                    if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) )
+                    {
+                        Plugin assembledPlugin = childPlugin;
+
+                        mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
+
+                        // fix for MNG-2221 (assembly cache was not being populated for later reference):
+                        assembledPlugins.add( assembledPlugin );
+                    }
+
+                    // if we're processing this as an inheritance-based merge, and
+                    // the parent's <inherited/> flag is not set, then we need to
+                    // clear the inherited flag in the merge result.
+                    if ( handleAsInheritance && ( parentInherited == null ) )
+                    {
+                        parentPlugin.unsetInheritanceApplied();
+                    }
+                }
+
+                // very important to use the parentPlugins List, rather than parentContainer.getPlugins()
+                // since this list is a local one, and may have been modified during processing.
+                List<Plugin> results =
+                    ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() );
+
+                childContainer.setPlugins( results );
+
+                childContainer.flushPluginMap();
+            }
+        }
+    }
+
+    public static List<Plugin> orderAfterMerge( List<Plugin> merged, List<Plugin> highPrioritySource,
+                                                List<Plugin> lowPrioritySource )
+    {
+        List<Plugin> results = new ArrayList<>();
+
+        if ( !merged.isEmpty() )
+        {
+            results.addAll( merged );
+        }
+
+        List<Plugin> missingFromResults = new ArrayList<>();
+
+        List<List<Plugin>> sources = new ArrayList<>();
+
+        sources.add( highPrioritySource );
+        sources.add( lowPrioritySource );
+
+        for ( List<Plugin> source : sources )
+        {
+            for ( Plugin item : source )
+            {
+                if ( results.contains( item ) )
+                {
+                    if ( !missingFromResults.isEmpty() )
+                    {
+                        int idx = results.indexOf( item );
+
+                        if ( idx < 0 )
+                        {
+                            idx = 0;
+                        }
+
+                        results.addAll( idx, missingFromResults );
+
+                        missingFromResults.clear();
+                    }
+                }
+                else
+                {
+                    missingFromResults.add( item );
+                }
+            }
+
+            if ( !missingFromResults.isEmpty() )
+            {
+                results.addAll( missingFromResults );
+
+                missingFromResults.clear();
+            }
+        }
+
+        return results;
+    }
+
+
+    public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
+    {
+        if ( ( child == null ) || ( parent == null ) )
+        {
+            // nothing to do.
+            return;
+        }
+
+        if ( parent.isExtensions() )
+        {
+            child.setExtensions( true );
+        }
+
+        if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
+        {
+            child.setVersion( parent.getVersion() );
+        }
+
+        Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
+        Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
+
+        childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+
+        child.setConfiguration( childConfiguration );
+
+        child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) );
+
+        // from here to the end of the method is dealing with merging of the <executions/> section.
+        String parentInherited = parent.getInherited();
+
+        boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited );
+
+        List<PluginExecution> parentExecutions = parent.getExecutions();
+
+        if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() )
+        {
+            List<PluginExecution> mergedExecutions = new ArrayList<>();
+
+            Map<String, PluginExecution> assembledExecutions = new TreeMap<>();
+
+            Map<String, PluginExecution> childExecutions = child.getExecutionsAsMap();
+
+            for ( PluginExecution parentExecution : parentExecutions )
+            {
+                String inherited = parentExecution.getInherited();
+
+                boolean parentExecInherited =
+                    parentIsInherited && ( ( inherited == null ) || Boolean.parseBoolean( inherited ) );
+
+                if ( !handleAsInheritance || parentExecInherited )
+                {
+                    PluginExecution assembled = parentExecution;
+
+                    PluginExecution childExecution = childExecutions.get( parentExecution.getId() );
+
+                    if ( childExecution != null )
+                    {
+                        mergePluginExecutionDefinitions( childExecution, parentExecution );
+
+                        assembled = childExecution;
+                    }
+                    else if ( handleAsInheritance && ( parentInherited == null ) )
+                    {
+                        parentExecution.unsetInheritanceApplied();
+                    }
+
+                    assembledExecutions.put( assembled.getId(), assembled );
+                    mergedExecutions.add( assembled );
+                }
+            }
+
+            for ( PluginExecution childExecution : child.getExecutions() )
+            {
+                if ( !assembledExecutions.containsKey( childExecution.getId() ) )
+                {
+                    mergedExecutions.add( childExecution );
+                }
+            }
+
+            child.setExecutions( mergedExecutions );
+
+            child.flushExecutionMap();
+        }
+
+    }
+
+    private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
+    {
+        if ( child.getPhase() == null )
+        {
+            child.setPhase( parent.getPhase() );
+        }
+
+        List<String> parentGoals = parent.getGoals();
+        List<String> childGoals = child.getGoals();
+
+        List<String> goals = new ArrayList<>();
+
+        if ( ( childGoals != null ) && !childGoals.isEmpty() )
+        {
+            goals.addAll( childGoals );
+        }
+
+        if ( parentGoals != null )
+        {
+            for (  String goal : parentGoals )
+            {
+                if ( !goals.contains( goal ) )
+                {
+                    goals.add( goal );
+                }
+            }
+        }
+
+        child.setGoals( goals );
+
+        Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
+        Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
+
+        childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+
+        child.setConfiguration( childConfiguration );
+    }
+
+    public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive )
+    {
+
+        List<Repository> repositories = new ArrayList<>( dominant );
+
+        for ( Repository repository : recessive )
+        {
+            if ( !repositories.contains( repository ) )
+            {
+                repositories.add( repository );
+            }
+        }
+
+        return repositories;
+    }
+
+    public static void mergeFilterLists( List<String> childFilters, List<String> parentFilters )
+    {
+        for ( String f : parentFilters )
+        {
+            if ( !childFilters.contains( f ) )
+            {
+                childFilters.add( f );
+            }
+        }
+    }
+
+    private static List<Dependency> mergeDependencyList( List<Dependency> child, List<Dependency> parent )
+    {
+        Map<String, Dependency> depsMap = new LinkedHashMap<>();
+
+        if ( parent != null )
+        {
+            for ( Dependency dependency : parent )
+            {
+                depsMap.put( dependency.getManagementKey(), dependency );
+            }
+        }
+
+        if ( child != null )
+        {
+            for ( Dependency dependency : child )
+            {
+                depsMap.put( dependency.getManagementKey(), dependency );
+            }
+        }
+
+        return new ArrayList<>( depsMap.values() );
+    }
+
+}
diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
index b7b9718..bc828ef 100644
--- a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
@@ -58,13 +58,13 @@
 import org.apache.maven.ProjectDependenciesResolver;
 import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.internal.ProjectArtifactFactory;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Organization;
 import org.apache.maven.model.Resource;
@@ -77,12 +77,14 @@
 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.InvalidProjectModelException;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingResult;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
+import org.apache.maven.repository.RepositorySystem;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
 import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
@@ -92,6 +94,9 @@
 import org.apache.maven.shared.filtering.MavenFileFilter;
 import org.apache.maven.shared.filtering.MavenFileFilterRequest;
 import org.apache.maven.shared.filtering.MavenFilteringException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.VelocityEngine;
@@ -251,8 +256,7 @@
      * Merges supplemental data model with artifact metadata. Useful when processing artifacts with
      * incomplete POM metadata.
      */
-    @Component
-    private ModelInheritanceAssembler inheritanceAssembler;
+    private ModelInheritanceAssembler inheritanceAssembler = new ModelInheritanceAssembler();
 
     /**
      * The resource bundles that will be retrieved and processed,
@@ -327,6 +331,12 @@
     private List<Resource> resources;
 
     /**
+     * Repository system, needed to create Artifact and Repository objects.
+     */
+    @Component
+    protected RepositorySystem repositorySystem;
+
+    /**
      * Artifact Resolver, needed to resolve and download the {@code resourceBundles}.
      */
     @Component
@@ -339,10 +349,10 @@
     private MavenFileFilter fileFilter;
 
     /**
-     * Artifact factory, needed to create artifacts.
+     * Project artifact factory, needed to create artifacts for the project dependencies.
      */
     @Component
-    private ArtifactFactory artifactFactory;
+    private ProjectArtifactFactory projectArtifactFactory;
 
     /**
      * The Maven session.
@@ -353,8 +363,8 @@
     /**
      * ProjectBuilder, needed to create projects from the artifacts.
      */
-    @Component( role = MavenProjectBuilder.class )
-    private MavenProjectBuilder mavenProjectBuilder;
+    @Component( role = ProjectBuilder.class )
+    private ProjectBuilder projectBuilder;
 
     /**
      */
@@ -637,53 +647,49 @@
 
         for ( Artifact artifact : artifacts )
         {
+            List<ArtifactRepository> remoteRepo = remoteArtifactRepositories;
+            if ( artifact.isSnapshot() )
+            {
+                VersionRange rng = VersionRange.createFromVersion( artifact.getBaseVersion() );
+                artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), rng,
+                                                artifact.getType(), artifact.getClassifier(), artifact.getScope(),
+                                                artifact.getArtifactHandler(), artifact.isOptional() );
+            }
+
+            getLog().debug( "Building project for " + artifact );
+            MavenProject p;
             try
             {
-                List<ArtifactRepository> remoteRepo = remoteArtifactRepositories;
-                if ( artifact.isSnapshot() )
-                {
-                    VersionRange rng = VersionRange.createFromVersion( artifact.getBaseVersion() );
-                    artifact =
-                        artifactFactory.createDependencyArtifact( artifact.getGroupId(), artifact.getArtifactId(), rng,
-                                                                  artifact.getType(), artifact.getClassifier(),
-                                                                  artifact.getScope(), null, artifact.isOptional() );
-                }
-
-                getLog().debug( "Building project for " + artifact );
-                MavenProject p;
-                try
-                {
-                    p = mavenProjectBuilder.buildFromRepository( artifact, remoteRepo, localRepository );
-                }
-                catch ( InvalidProjectModelException e )
-                {
-                    getLog().warn( "Invalid project model for artifact [" + artifact.getArtifactId() + ":"
-                                       + artifact.getGroupId() + ":" + artifact.getVersion() + "]. "
-                                       + "It will be ignored by the remote resources Mojo." );
-                    continue;
-                }
-
-                String supplementKey =
-                    generateSupplementMapKey( p.getModel().getGroupId(), p.getModel().getArtifactId() );
-
-                if ( supplementModels.containsKey( supplementKey ) )
-                {
-                    Model mergedModel = mergeModels( p.getModel(), supplementModels.get( supplementKey ) );
-                    MavenProject mergedProject = new MavenProject( mergedModel );
-                    projects.add( mergedProject );
-                    mergedProject.setArtifact( artifact );
-                    mergedProject.setVersion( artifact.getVersion() );
-                    getLog().debug( "Adding project with groupId [" + mergedProject.getGroupId() + "] (supplemented)" );
-                }
-                else
-                {
-                    projects.add( p );
-                    getLog().debug( "Adding project with groupId [" + p.getGroupId() + "]" );
-                }
+                ProjectBuildingRequest req = new DefaultProjectBuildingRequest()
+                        .setLocalRepository( localRepository )
+                        .setRemoteRepositories( remoteRepo );
+                ProjectBuildingResult res = projectBuilder.build( artifact, req );
+                p = res.getProject();
             }
             catch ( ProjectBuildingException e )
             {
-                throw new IllegalStateException( e.getMessage(), e );
+                getLog().warn( "Invalid project model for artifact [" + artifact.getArtifactId() + ":"
+                                   + artifact.getGroupId() + ":" + artifact.getVersion() + "]. "
+                                   + "It will be ignored by the remote resources Mojo." );
+                continue;
+            }
+
+            String supplementKey =
+                generateSupplementMapKey( p.getModel().getGroupId(), p.getModel().getArtifactId() );
+
+            if ( supplementModels.containsKey( supplementKey ) )
+            {
+                Model mergedModel = mergeModels( p.getModel(), supplementModels.get( supplementKey ) );
+                MavenProject mergedProject = new MavenProject( mergedModel );
+                projects.add( mergedProject );
+                mergedProject.setArtifact( artifact );
+                mergedProject.setVersion( artifact.getVersion() );
+                getLog().debug( "Adding project with groupId [" + mergedProject.getGroupId() + "] (supplemented)" );
+            }
+            else
+            {
+                projects.add( p );
+                getLog().debug( "Adding project with groupId [" + p.getGroupId() + "]" );
             }
         }
         Collections.sort( projects, new ProjectComparator() );
@@ -696,7 +702,7 @@
         {
             if ( runOnlyAtExecutionRoot )
             {
-                List<MavenProject> projects = mavenSession.getSortedProjects();
+                List<MavenProject> projects = mavenSession.getProjects();
                 return dependencyResolver.resolve( projects, Arrays.asList( resolveScopes ), mavenSession );
             }
             else
@@ -721,14 +727,14 @@
     {
         Set<Artifact> artifacts = new LinkedHashSet<>();
 
-        List<MavenProject> projects = mavenSession.getSortedProjects();
+        List<MavenProject> projects = mavenSession.getProjects();
         for ( MavenProject p : projects )
         {
             if ( p.getDependencyArtifacts() == null )
             {
                 try
                 {
-                    Set<Artifact> depArtifacts = p.createArtifacts( artifactFactory, null, null );
+                    Set<Artifact> depArtifacts = projectArtifactFactory.createArtifacts( p );
 
                     if ( depArtifacts != null && !depArtifacts.isEmpty() )
                     {
@@ -1085,57 +1091,52 @@
     {
         List<File> bundleArtifacts = new ArrayList<>();
 
-        try
+        for ( String artifactDescriptor : bundles )
         {
-            for ( String artifactDescriptor : bundles )
-            {
-                getLog().info( "Preparing remote bundle " + artifactDescriptor );
-                // groupId:artifactId:version[:type[:classifier]]
-                String[] s = artifactDescriptor.split( ":" );
+            getLog().info( "Preparing remote bundle " + artifactDescriptor );
+            // groupId:artifactId:version[:type[:classifier]]
+            String[] s = artifactDescriptor.split( ":" );
 
-                File artifactFile = null;
-                // check if the artifact is part of the reactor
-                if ( mavenSession != null )
+            File artifactFile = null;
+            // check if the artifact is part of the reactor
+            if ( mavenSession != null )
+            {
+                List<MavenProject> list = mavenSession.getProjects();
+                for ( MavenProject p : list )
                 {
-                    List<MavenProject> list = mavenSession.getSortedProjects();
-                    for ( MavenProject p : list )
+                    if ( s[0].equals( p.getGroupId() ) && s[1].equals( p.getArtifactId() )
+                        && s[2].equals( p.getVersion() ) )
                     {
-                        if ( s[0].equals( p.getGroupId() ) && s[1].equals( p.getArtifactId() )
-                            && s[2].equals( p.getVersion() ) )
+                        if ( s.length >= 4 && "test-jar".equals( s[3] ) )
                         {
-                            if ( s.length >= 4 && "test-jar".equals( s[3] ) )
-                            {
-                                artifactFile = new File( p.getBuild().getTestOutputDirectory() );
-                            }
-                            else
-                            {
-                                artifactFile = new File( p.getBuild().getOutputDirectory() );
-                            }
+                            artifactFile = new File( p.getBuild().getTestOutputDirectory() );
+                        }
+                        else
+                        {
+                            artifactFile = new File( p.getBuild().getOutputDirectory() );
                         }
                     }
                 }
-                if ( artifactFile == null || !artifactFile.exists() )
-                {
-                    String type = ( s.length >= 4 ? s[3] : "jar" );
-                    String classifier = ( s.length == 5 ? s[4] : null );
-                    Artifact artifact =
-                        artifactFactory.createDependencyArtifact( s[0], s[1], VersionRange.createFromVersion( s[2] ),
-                                                                  type, classifier, Artifact.SCOPE_RUNTIME );
-
-                    artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
-
-                    artifactFile = artifact.getFile();
-                }
-                bundleArtifacts.add( artifactFile );
             }
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw new MojoExecutionException( "Error downloading resources archive.", e );
-        }
-        catch ( ArtifactNotFoundException e )
-        {
-            throw new MojoExecutionException( "Resources archive cannot be found.", e );
+            if ( artifactFile == null || !artifactFile.exists() )
+            {
+                String type = ( s.length >= 4 ? s[3] : "jar" );
+                String classifier = ( s.length == 5 ? s[4] : null );
+                Artifact artifact = repositorySystem.createArtifactWithClassifier( s[0], s[1], s[2], type, classifier );
+
+                try
+                {
+                    ArtifactResult result = artifactResolver.resolveArtifact(
+                            mavenSession.getProjectBuildingRequest(), artifact );
+                    artifactFile = result.getArtifact().getFile();
+                }
+                catch ( ArtifactResolverException e )
+                {
+                    throw new MojoExecutionException( "Error processing remote resources", e );
+                }
+
+            }
+            bundleArtifacts.add( artifactFile );
         }
 
         return bundleArtifacts;
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
index 24c928f..87b34ba 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
@@ -22,13 +22,21 @@
 import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.DefaultMavenExecutionResult;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.execution.ReactorManager;
 import org.apache.maven.plugin.resources.remote.stub.MavenProjectBuildStub;
 import org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.logging.console.ConsoleLoggerManager;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
@@ -43,6 +51,12 @@
 import java.util.jar.JarOutputStream;
 import java.util.zip.ZipEntry;
 import org.codehaus.plexus.util.IOUtil;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
 
 
 /**
@@ -55,6 +69,8 @@
     static final String DEFAULT_BUNDLE_POM_PATH = "target/test-classes/unit/rrmojotest/bundle-plugin-config.xml";
     static final String DEFAULT_PROCESS_POM_PATH = "target/test-classes/unit/rrmojotest/process-plugin-config.xml";
 
+    private final String LOCAL_REPO = "target/local-repo/";
+
     @Override
     public void setUp()
         throws Exception
@@ -496,15 +512,21 @@
     {
         final ProcessRemoteResourcesMojo mojo = lookupProcessMojo();
 
-        MavenSession session = new MavenSession( getContainer(),
-                                    null, //Settings settings,
-                                    null, //ArtifactRepository localRepository,
-                                    null, //EventDispatcher eventDispatcher,
-                                    new ReactorManager( new ArrayList<MavenProject>() ),
-                                    Arrays.asList( "install" ),
-                                    project.getBasedir().toString(),
-                                    new Properties(),
-                                    Calendar.getInstance().getTime() );
+        ArtifactRepository localRepository = mojo.repositorySystem.createLocalRepository( new File( LOCAL_REPO ) );
+        DefaultRepositorySystemSession reposession = MavenRepositorySystemUtils.newSession();
+        reposession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
+                .newInstance( reposession, new LocalRepository( new File( LOCAL_REPO ) ) ) );
+
+        DefaultMavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        request.setLocalRepository( localRepository );
+        request = new DefaultMavenExecutionRequest();
+        request.setUserProperties( null );
+        request.setLocalRepository( localRepository );
+        request.setGoals( Arrays.asList( "install" ) );
+        request.setBaseDirectory( project.getBasedir() );
+        request.setStartTime( Calendar.getInstance().getTime() );
+        MavenSession session = new MavenSession( getContainer(), reposession, request, new DefaultMavenExecutionResult() );
+        session.setProjects( Arrays.asList( project ) );
 
         setVariableValueToObject( mojo, "project", project );
         setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
index 5f59c9a..fc52d6f 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java
@@ -376,10 +376,4 @@
         return 0;
     }
 
-    @Override
-    public ArtifactMetadata getMetadata( Class<?> metadataClass )
-    {
-        return null;
-    }
-
 }
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
index 0107561..07514ab 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java
@@ -25,6 +25,8 @@
 import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Profile;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
@@ -154,15 +156,14 @@
     {
         // the pom should be located in the isolated dummy root
         super.setFile( new File( getBasedir(), "pom.xml" ) );
-        super.setDependencyArtifacts( new HashSet<>() );
-        super.setArtifacts( new HashSet<>() );
-        super.setPluginArtifacts( new HashSet<>() );
-        super.setReportArtifacts( new HashSet<>() );
-        super.setExtensionArtifacts( new HashSet<>() );
-        super.setRemoteArtifactRepositories( new LinkedList<>() );
-        super.setPluginArtifactRepositories( new LinkedList<>() );
-        super.setCollectedProjects( new LinkedList<>() );
-        super.setActiveProfiles( new LinkedList<>() );
+        super.setDependencyArtifacts( new HashSet<Artifact>() );
+        super.setArtifacts( new HashSet<Artifact>() );
+        super.setReportArtifacts( new HashSet<Artifact>() );
+        super.setExtensionArtifacts( new HashSet<Artifact>() );
+        super.setRemoteArtifactRepositories( new LinkedList<ArtifactRepository>() );
+        super.setPluginArtifactRepositories( new LinkedList<ArtifactRepository>() );
+        super.setCollectedProjects( new LinkedList<MavenProject>() );
+        super.setActiveProfiles( new LinkedList<Profile>() );
         super.setOriginalModel( null );
         super.setExecutionProject( this );
         super.setArtifact( artifact );