You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2018/02/08 22:53:42 UTC

[33/49] maven git commit: [MNG-6300] Multi module release creates empty directories in war file instead of jars

[MNG-6300] Multi module release creates empty directories in war file instead of jars


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/98af937b
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/98af937b
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/98af937b

Branch: refs/heads/MNG-6255
Commit: 98af937bc6298e82e489b5f0cd3fb0a1c3d37109
Parents: eee06f7
Author: rfscholte <rf...@apache.org>
Authored: Fri Dec 22 14:25:46 2017 +0100
Committer: rfscholte <rf...@apache.org>
Committed: Fri Dec 22 14:25:46 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/RepositoryUtils.java  |  69 +++++
 .../internal/LifecycleDependencyResolver.java   |  36 ++-
 .../org/apache/maven/plugin/CacheUtils.java     |  68 -----
 .../plugin/DefaultPluginArtifactsCache.java     |  32 +--
 .../plugin/DefaultPluginDescriptorCache.java    |   7 +-
 .../maven/plugin/DefaultPluginRealmCache.java   |  36 ++-
 .../plugin/DefaultProjectArtifactsCache.java    | 256 -------------------
 .../maven/plugin/ProjectArtifactsCache.java     |  90 -------
 .../artifact/DefaultProjectArtifactsCache.java  | 246 ++++++++++++++++++
 .../project/artifact/ProjectArtifactsCache.java |  90 +++++++
 .../AbstractCoreMavenComponentTestCase.java     |  30 ++-
 .../LifecycleDependencyResolverTest.java        |  90 +++++++
 .../lifecycle-dependency-resolver/lib/pom.xml   |  32 +++
 .../lifecycle-dependency-resolver/pom.xml       |  58 +++++
 .../lifecycle-dependency-resolver/war/pom.xml   |  53 ++++
 15 files changed, 723 insertions(+), 470 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
index 52442b7..00f1327 100644
--- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
+++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
@@ -22,14 +22,17 @@ package org.apache.maven;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.artifact.ArtifactProperties;
 import org.eclipse.aether.artifact.ArtifactType;
@@ -44,6 +47,8 @@ import org.eclipse.aether.repository.Authentication;
 import org.eclipse.aether.repository.Proxy;
 import org.eclipse.aether.repository.RemoteRepository;
 import org.eclipse.aether.repository.RepositoryPolicy;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
 import org.eclipse.aether.util.repository.AuthenticationBuilder;
 
 /**
@@ -364,4 +369,68 @@ public class RepositoryUtils
         }
         return artifacts;
     }
+
+    public static WorkspaceRepository getWorkspace( RepositorySystemSession session )
+    {
+        WorkspaceReader reader = session.getWorkspaceReader();
+        return ( reader != null ) ? reader.getRepository() : null;
+    }
+
+    public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 )
+    {
+        if ( r1.size() != r2.size() )
+        {
+            return false;
+        }
+    
+        for ( Iterator<RemoteRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
+        {
+            if ( !repositoryEquals( it1.next(), it2.next() ) )
+            {
+                return false;
+            }
+        }
+    
+        return true;
+    }
+
+    public static int repositoriesHashCode( List<RemoteRepository> repositories )
+    {
+        int result = 17;
+        for ( RemoteRepository repository : repositories )
+        {
+            result = 31 * result + repositoryHashCode( repository );
+        }
+        return result;
+    }
+
+    private static int repositoryHashCode( RemoteRepository repository )
+    {
+        int result = 17;
+        Object obj = repository.getUrl();
+        result = 31 * result + ( obj != null ? obj.hashCode() : 0 );
+        return result;
+    }
+
+    private static boolean policyEquals( RepositoryPolicy p1, RepositoryPolicy p2 )
+    {
+        if ( p1 == p2 )
+        {
+            return true;
+        }
+        // update policy doesn't affect contents
+        return p1.isEnabled() == p2.isEnabled() && Objects.equals( p1.getChecksumPolicy(), p2.getChecksumPolicy() );
+    }
+
+    private static boolean repositoryEquals( RemoteRepository r1, RemoteRepository r2 )
+    {
+        if ( r1 == r2 )
+        {
+            return true;
+        }
+    
+        return Objects.equals( r1.getId(), r2.getId() ) && Objects.equals( r1.getUrl(), r2.getUrl() )
+            && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) )
+            && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) );
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
index 504274f..f7636ef 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
@@ -19,6 +19,8 @@ package org.apache.maven.lifecycle.internal;
  * under the License.
  */
 
+import java.io.File;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -37,13 +39,13 @@ import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.lifecycle.LifecycleExecutionException;
-import org.apache.maven.plugin.ProjectArtifactsCache;
 import org.apache.maven.project.DefaultDependencyResolutionRequest;
 import org.apache.maven.project.DependencyResolutionException;
 import org.apache.maven.project.DependencyResolutionResult;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectDependenciesResolver;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.project.artifact.ProjectArtifactsCache;
 import org.codehaus.plexus.logging.Logger;
 import org.eclipse.aether.graph.Dependency;
 import org.eclipse.aether.graph.DependencyFilter;
@@ -128,7 +130,7 @@ public class LifecycleDependencyResolver
                 }
             }
             
-            Set<Artifact> artifacts;
+            Set<Artifact> resolvedArtifacts;
             ProjectArtifactsCache.Key cacheKey = projectArtifactsCache.createKey( project,  scopesToCollect, 
                 scopesToResolve, aggregating, session.getRepositorySession() );
             ProjectArtifactsCache.CacheRecord recordArtifacts;
@@ -136,15 +138,15 @@ public class LifecycleDependencyResolver
             
             if ( recordArtifacts != null )
             {
-                artifacts = recordArtifacts.artifacts;
+                resolvedArtifacts = recordArtifacts.artifacts;
             }
             else
             {
                 try
                 {
-                    artifacts = getDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, 
-                        projectArtifacts );
-                    recordArtifacts = projectArtifactsCache.put( cacheKey, artifacts );
+                    resolvedArtifacts = getDependencies( project, scopesToCollect, scopesToResolve, session,
+                                                         aggregating, projectArtifacts );
+                    recordArtifacts = projectArtifactsCache.put( cacheKey, resolvedArtifacts );
                 }
                 catch ( LifecycleExecutionException e )
                 {
@@ -155,13 +157,31 @@ public class LifecycleDependencyResolver
             }
             projectArtifactsCache.register( project, cacheKey, recordArtifacts );
 
-            project.setResolvedArtifacts( artifacts );
+            Map<Artifact, File> reactorProjects = new HashMap<>( session.getProjects().size() );
+            for ( MavenProject reactorProject : session.getProjects() )
+            {
+                reactorProjects.put( reactorProject.getArtifact(), reactorProject.getArtifact().getFile() );
+            }
 
             Map<String, Artifact> map = new HashMap<>();
-            for ( Artifact artifact : artifacts )
+            for ( Artifact artifact : resolvedArtifacts )
             {
+                /**
+                 * MNG-6300: resolvedArtifacts can be cache result; this ensures reactor files are always up to date 
+                 * During lifecycle the Artifact.getFile() can change from target/classes to the actual jar.
+                 * This clearly shows that target/classes should not be abused as artifactFile just for the classpath
+                 */
+                File reactorProjectFile = reactorProjects.get( artifact );
+                if ( reactorProjectFile != null )
+                {
+                    artifact.setFile( reactorProjectFile );
+                }
+
                 map.put( artifact.getDependencyConflictId(), artifact );
             }
+            
+            project.setResolvedArtifacts( resolvedArtifacts );
+            
             for ( Artifact artifact : project.getDependencyArtifacts() )
             {
                 if ( artifact.getFile() == null )

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
index a73e1ef..7196ce9 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
@@ -25,11 +25,6 @@ import java.util.List;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Exclusion;
 import org.apache.maven.model.Plugin;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.repository.WorkspaceRepository;
 
 /**
  * @author Benjamin Bentmann
@@ -47,63 +42,6 @@ class CacheUtils
         return obj != null ? obj.hashCode() : 0;
     }
 
-    public static int repositoriesHashCode( List<RemoteRepository> repositories )
-    {
-        int result = 17;
-        for ( RemoteRepository repository : repositories )
-        {
-            result = 31 * result + repositoryHashCode( repository );
-        }
-        return result;
-    }
-
-    private static int repositoryHashCode( RemoteRepository repository )
-    {
-        int result = 17;
-        result = 31 * result + hash( repository.getUrl() );
-        return result;
-    }
-
-    private static boolean repositoryEquals( RemoteRepository r1, RemoteRepository r2 )
-    {
-        if ( r1 == r2 )
-        {
-            return true;
-        }
-
-        return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() )
-            && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) )
-            && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) );
-    }
-
-    private static boolean policyEquals( RepositoryPolicy p1, RepositoryPolicy p2 )
-    {
-        if ( p1 == p2 )
-        {
-            return true;
-        }
-        // update policy doesn't affect contents
-        return p1.isEnabled() == p2.isEnabled() && eq( p1.getChecksumPolicy(), p2.getChecksumPolicy() );
-    }
-
-    public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 )
-    {
-        if ( r1.size() != r2.size() )
-        {
-            return false;
-        }
-
-        for ( Iterator<RemoteRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
-        {
-            if ( !repositoryEquals( it1.next(), it2.next() ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
     public static int pluginHashCode( Plugin plugin )
     {
         int hash = 17;
@@ -202,10 +140,4 @@ class CacheUtils
         return true;
     }
 
-    public static WorkspaceRepository getWorkspace( RepositorySystemSession session )
-    {
-        WorkspaceReader reader = session.getWorkspaceReader();
-        return ( reader != null ) ? reader.getRepository() : null;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
index 6a08681..b49e25e 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
@@ -23,9 +23,11 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.lang3.Validate;
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.project.MavenProject;
@@ -48,7 +50,6 @@ public class DefaultPluginArtifactsCache
     protected static class CacheKey
         implements Key
     {
-
         private final Plugin plugin;
 
         private final WorkspaceRepository workspace;
@@ -65,7 +66,7 @@ public class DefaultPluginArtifactsCache
                          RepositorySystemSession session )
         {
             this.plugin = plugin.clone();
-            workspace = CacheUtils.getWorkspace( session );
+            workspace = RepositoryUtils.getWorkspace( session );
             this.localRepo = session.getLocalRepository();
             this.repositories = new ArrayList<>( repositories.size() );
             for ( RemoteRepository repository : repositories )
@@ -83,10 +84,10 @@ public class DefaultPluginArtifactsCache
 
             int hash = 17;
             hash = hash * 31 + CacheUtils.pluginHashCode( plugin );
-            hash = hash * 31 + hash( workspace );
-            hash = hash * 31 + hash( localRepo );
-            hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
-            hash = hash * 31 + hash( extensionFilter );
+            hash = hash * 31 + Objects.hashCode( workspace );
+            hash = hash * 31 + Objects.hashCode( localRepo );
+            hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories );
+            hash = hash * 31 + Objects.hashCode( extensionFilter );
             this.hashCode = hash;
         }
 
@@ -102,11 +103,6 @@ public class DefaultPluginArtifactsCache
             return hashCode;
         }
 
-        private static int hash( Object obj )
-        {
-            return obj != null ? obj.hashCode() : 0;
-        }
-
         @Override
         public boolean equals( Object o )
         {
@@ -122,16 +118,12 @@ public class DefaultPluginArtifactsCache
 
             CacheKey that = (CacheKey) o;
 
-            return CacheUtils.pluginEquals( plugin, that.plugin ) && eq( workspace, that.workspace )
-                && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( repositories, that.repositories )
-                && eq( filter, that.filter );
+            return CacheUtils.pluginEquals( plugin, that.plugin ) 
+                && Objects.equals( workspace, that.workspace )
+                && Objects.equals( localRepo, that.localRepo ) 
+                && RepositoryUtils.repositoriesEquals( repositories, that.repositories )
+                && Objects.equals( filter, that.filter );
         }
-
-        private static <T> boolean eq( T s1, T s2 )
-        {
-            return s1 != null ? s1.equals( s2 ) : s2 == null;
-        }
-
     }
 
     protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<>();

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java
index 5968332..32228ba 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -146,7 +147,7 @@ public class DefaultPluginDescriptorCache
             artifactId = plugin.getArtifactId();
             version = plugin.getVersion();
 
-            workspace = CacheUtils.getWorkspace( session );
+            workspace = RepositoryUtils.getWorkspace( session );
             localRepo = session.getLocalRepository();
             this.repositories = new ArrayList<>( repositories.size() );
             for ( RemoteRepository repository : repositories )
@@ -167,7 +168,7 @@ public class DefaultPluginDescriptorCache
             hash = hash * 31 + version.hashCode();
             hash = hash * 31 + hash( workspace );
             hash = hash * 31 + localRepo.hashCode();
-            hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
+            hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories );
             this.hashCode = hash;
         }
 
@@ -195,7 +196,7 @@ public class DefaultPluginDescriptorCache
             return eq( this.artifactId, that.artifactId ) && eq( this.groupId, that.groupId )
                 && eq( this.version, that.version ) && eq( this.localRepo, that.localRepo )
                 && eq( this.workspace, that.workspace )
-                && CacheUtils.repositoriesEquals( this.repositories, that.repositories );
+                && RepositoryUtils.repositoriesEquals( this.repositories, that.repositories );
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
index 0a6da8d..1c09d9b 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
@@ -23,9 +23,11 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.lang3.Validate;
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.project.MavenProject;
@@ -72,7 +74,7 @@ public class DefaultPluginRealmCache
                          RepositorySystemSession session )
         {
             this.plugin = plugin.clone();
-            this.workspace = CacheUtils.getWorkspace( session );
+            this.workspace = RepositoryUtils.getWorkspace( session );
             this.localRepo = session.getLocalRepository();
             this.repositories = new ArrayList<>( repositories.size() );
             for ( RemoteRepository repository : repositories )
@@ -93,12 +95,12 @@ public class DefaultPluginRealmCache
 
             int hash = 17;
             hash = hash * 31 + CacheUtils.pluginHashCode( plugin );
-            hash = hash * 31 + hash( workspace );
-            hash = hash * 31 + hash( localRepo );
-            hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
-            hash = hash * 31 + hash( parentRealm );
+            hash = hash * 31 + Objects.hashCode( workspace );
+            hash = hash * 31 + Objects.hashCode( localRepo );
+            hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories );
+            hash = hash * 31 + Objects.hashCode( parentRealm );
             hash = hash * 31 + this.foreignImports.hashCode();
-            hash = hash * 31 + hash( dependencyFilter );
+            hash = hash * 31 + Objects.hashCode( dependencyFilter );
             this.hashCode = hash;
         }
 
@@ -114,11 +116,6 @@ public class DefaultPluginRealmCache
             return hashCode;
         }
 
-        private static int hash( Object obj )
-        {
-            return obj != null ? obj.hashCode() : 0;
-        }
-
         @Override
         public boolean equals( Object o )
         {
@@ -134,17 +131,14 @@ public class DefaultPluginRealmCache
 
             CacheKey that = (CacheKey) o;
 
-            return parentRealm == that.parentRealm && CacheUtils.pluginEquals( plugin, that.plugin )
-                && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo )
-                && CacheUtils.repositoriesEquals( this.repositories, that.repositories ) && eq( filter, that.filter )
-                && eq( foreignImports, that.foreignImports );
+            return parentRealm == that.parentRealm 
+                && CacheUtils.pluginEquals( plugin, that.plugin )
+                && Objects.equals( workspace, that.workspace ) 
+                && Objects.equals( localRepo, that.localRepo )
+                && RepositoryUtils.repositoriesEquals( this.repositories, that.repositories ) 
+                && Objects.equals( filter, that.filter )
+                && Objects.equals( foreignImports, that.foreignImports );
         }
-
-        private static <T> boolean eq( T s1, T s2 )
-        {
-            return s1 != null ? s1.equals( s2 ) : s2 == null;
-        }
-
     }
 
     protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<>();

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java
deleted file mode 100644
index 1eaa627..0000000
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.apache.maven.plugin;
-
-/*
- * 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.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.commons.lang3.Validate;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.lifecycle.LifecycleExecutionException;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.annotations.Component;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.WorkspaceRepository;
-
-/**
- * @author Igor Fedorenko
- * @author Benjamin Bentmann
- * @author Anton Tanasenko
- */
-@Component( role = ProjectArtifactsCache.class )
-public class DefaultProjectArtifactsCache
-    implements ProjectArtifactsCache
-{
-
-    protected static class CacheKey
-        implements Key
-    {
-
-        private final String groupId;
-        
-        private final String artifactId;
-        
-        private final String version;
-        
-        private final Set<String> dependencyArtifacts;
-
-        private final WorkspaceRepository workspace;
-
-        private final LocalRepository localRepo;
-
-        private final List<RemoteRepository> repositories;
-        
-        private final Set<String> collect;
-        
-        private final Set<String> resolve;
-        
-        private boolean aggregating;
-
-        private final int hashCode;
-
-        public CacheKey( MavenProject project, List<RemoteRepository> repositories,
-            Collection<String> scopesToCollect, Collection<String> scopesToResolve, boolean aggregating,
-            RepositorySystemSession session )
-        {
-            
-            groupId = project.getGroupId();
-            artifactId = project.getArtifactId();
-            version = project.getVersion();
-            
-            Set<String> deps = new HashSet<>();
-            if ( project.getDependencyArtifacts() != null )
-            {
-              for ( Artifact dep: project.getDependencyArtifacts() )
-              {
-                deps.add( dep.toString() );
-              }
-            }
-            dependencyArtifacts = Collections.unmodifiableSet( deps );
-            
-            workspace = CacheUtils.getWorkspace( session );
-            this.localRepo = session.getLocalRepository();
-            this.repositories = new ArrayList<>( repositories.size() );
-            for ( RemoteRepository repository : repositories )
-            {
-                if ( repository.isRepositoryManager() )
-                {
-                    this.repositories.addAll( repository.getMirroredRepositories() );
-                }
-                else
-                {
-                    this.repositories.add( repository );
-                }
-            }
-            collect = scopesToCollect == null
-                ? Collections.<String>emptySet() 
-                : Collections.unmodifiableSet( new HashSet<>( scopesToCollect ) );
-            resolve = scopesToResolve == null 
-                ? Collections.<String>emptySet() 
-                : Collections.unmodifiableSet( new HashSet<>( scopesToResolve ) );
-            this.aggregating = aggregating;
-
-            int hash = 17;
-            hash = hash * 31 + hash( groupId );
-            hash = hash * 31 + hash( artifactId );
-            hash = hash * 31 + hash( version );
-            hash = hash * 31 + hash( dependencyArtifacts );
-            hash = hash * 31 + hash( workspace );
-            hash = hash * 31 + hash( localRepo );
-            hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
-            hash = hash * 31 + hash( collect );
-            hash = hash * 31 + hash( resolve );
-            hash = hash * 31 + hash( aggregating );
-            this.hashCode = hash;
-        }
-
-        @Override
-        public String toString()
-        {
-            return groupId + ":" + artifactId + ":" + version;
-        }
-
-        @Override
-        public int hashCode()
-        {
-            return hashCode;
-        }
-
-        private static int hash( Object obj )
-        {
-            return obj != null ? obj.hashCode() : 0;
-        }
-
-        @Override
-        public boolean equals( Object o )
-        {
-            if ( o == this )
-            {
-                return true;
-            }
-
-            if ( !( o instanceof CacheKey ) )
-            {
-                return false;
-            }
-
-            CacheKey that = (CacheKey) o;
-
-            return eq( groupId, that.groupId ) && eq( artifactId, that.artifactId ) && eq( version, that.version ) 
-                && eq( dependencyArtifacts, that.dependencyArtifacts )
-                && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) 
-                && CacheUtils.repositoriesEquals( repositories, that.repositories ) && eq( collect, that.collect ) 
-                && eq( resolve, that.resolve ) && aggregating == that.aggregating;
-        }
-
-        private static <T> boolean eq( T s1, T s2 )
-        {
-            return s1 != null ? s1.equals( s2 ) : s2 == null;
-        }
-
-    }
-
-    protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<>();
-
-    public Key createKey( MavenProject project, Collection<String> scopesToCollect,
-        Collection<String> scopesToResolve, boolean aggregating, RepositorySystemSession session )
-    {
-        return new CacheKey( project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve, 
-            aggregating, session );
-    }
-
-    public CacheRecord get( Key key )
-        throws LifecycleExecutionException
-    {
-        CacheRecord cacheRecord = cache.get( key );
-
-        if ( cacheRecord != null && cacheRecord.exception != null )
-        {
-            throw cacheRecord.exception;
-        }
-
-        return cacheRecord;
-    }
-
-    public CacheRecord put( Key key, Set<Artifact> projectArtifacts )
-    {
-        Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" );
-
-        assertUniqueKey( key );
-
-        CacheRecord record =
-            new CacheRecord( Collections.unmodifiableSet( new HashSet<>( projectArtifacts ) ) );
-
-        cache.put( key, record );
-
-        return record;
-    }
-
-    protected void assertUniqueKey( Key key )
-    {
-        if ( cache.containsKey( key ) )
-        {
-            throw new IllegalStateException( "Duplicate artifact resolution result for project " + key );
-        }
-    }
-
-    public CacheRecord put( Key key, LifecycleExecutionException exception )
-    {
-        Validate.notNull( exception, "exception cannot be null" );
-
-        assertUniqueKey( key );
-
-        CacheRecord record = new CacheRecord( exception );
-
-        cache.put( key, record );
-
-        return record;
-    }
-
-    public void flush()
-    {
-        cache.clear();
-    }
-
-    protected static int pluginHashCode( Plugin plugin )
-    {
-        return CacheUtils.pluginHashCode( plugin );
-    }
-
-    protected static boolean pluginEquals( Plugin a, Plugin b )
-    {
-        return CacheUtils.pluginEquals( a, b );
-    }
-
-    public void register( MavenProject project, Key cacheKey, CacheRecord record )
-    {
-        // default cache does not track record usage
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java
deleted file mode 100644
index 42a95e5..0000000
--- a/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.maven.plugin;
-
-/*
- * 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.Collection;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.lifecycle.LifecycleExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.eclipse.aether.RepositorySystemSession;
-/**
- * Caches project artifacts. <strong>Warning:</strong> This is an internal utility interface that is only public for
- * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without
- * prior notice.
- *
- * @author Igor Fedorenko
- * @author Benjamin Bentmann
- * @author Anton Tanasenko
- */
-public interface ProjectArtifactsCache
-{
-
-    /**
-     * A cache key.
-     */
-    interface Key
-    {
-        // marker interface for cache keys
-    }
-
-    static class CacheRecord
-    {
-
-        public final Set<Artifact> artifacts;
-
-        public final LifecycleExecutionException exception;
-
-        public CacheRecord( Set<Artifact> artifacts )
-        {
-            this.artifacts = artifacts;
-            this.exception = null;
-        }
-
-        public CacheRecord( LifecycleExecutionException exception )
-        {
-            this.artifacts = null;
-            this.exception = exception;
-        }
-    }
-
-    Key createKey( MavenProject project, Collection<String> scopesToCollect, Collection<String> scopesToResolve, 
-        boolean aggregating, RepositorySystemSession session );
-
-    CacheRecord get( Key key ) throws LifecycleExecutionException;
-
-    CacheRecord put( Key key, Set<Artifact> pluginArtifacts );
-
-    CacheRecord put( Key key, LifecycleExecutionException e );
-
-    void flush();
-
-    /**
-     * Registers the specified cache record for usage with the given project. Integrators can use the information
-     * collected from this method in combination with a custom cache implementation to dispose unused records from the
-     * cache.
-     *
-     * @param project The project that employs the plugin realm, must not be {@code null}.
-     * @param record The cache record being used for the project, must not be {@code null}.
-     */
-    void register( MavenProject project, Key cacheKey, CacheRecord record );
-
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
new file mode 100644
index 0000000..87d2e44
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
@@ -0,0 +1,246 @@
+package org.apache.maven.project.artifact;
+
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.maven.RepositoryUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.lifecycle.LifecycleExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.annotations.Component;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.WorkspaceRepository;
+
+/**
+ * @author Igor Fedorenko
+ * @author Benjamin Bentmann
+ * @author Anton Tanasenko
+ */
+@Component( role = ProjectArtifactsCache.class )
+public class DefaultProjectArtifactsCache
+    implements ProjectArtifactsCache
+{
+
+    protected static class CacheKey
+        implements Key
+    {
+
+        private final String groupId;
+        
+        private final String artifactId;
+        
+        private final String version;
+        
+        private final Set<String> dependencyArtifacts;
+
+        private final WorkspaceRepository workspace;
+
+        private final LocalRepository localRepo;
+
+        private final List<RemoteRepository> repositories;
+        
+        private final Set<String> collect;
+        
+        private final Set<String> resolve;
+        
+        private boolean aggregating;
+
+        private final int hashCode;
+
+        public CacheKey( MavenProject project, List<RemoteRepository> repositories,
+            Collection<String> scopesToCollect, Collection<String> scopesToResolve, boolean aggregating,
+            RepositorySystemSession session )
+        {
+            
+            groupId = project.getGroupId();
+            artifactId = project.getArtifactId();
+            version = project.getVersion();
+            
+            Set<String> deps = new HashSet<>();
+            if ( project.getDependencyArtifacts() != null )
+            {
+              for ( Artifact dep: project.getDependencyArtifacts() )
+              {
+                deps.add( dep.toString() );
+              }
+            }
+            dependencyArtifacts = Collections.unmodifiableSet( deps );
+            
+            workspace = RepositoryUtils.getWorkspace( session );
+            this.localRepo = session.getLocalRepository();
+            this.repositories = new ArrayList<>( repositories.size() );
+            for ( RemoteRepository repository : repositories )
+            {
+                if ( repository.isRepositoryManager() )
+                {
+                    this.repositories.addAll( repository.getMirroredRepositories() );
+                }
+                else
+                {
+                    this.repositories.add( repository );
+                }
+            }
+            collect = scopesToCollect == null
+                ? Collections.<String>emptySet() 
+                : Collections.unmodifiableSet( new HashSet<>( scopesToCollect ) );
+            resolve = scopesToResolve == null 
+                ? Collections.<String>emptySet() 
+                : Collections.unmodifiableSet( new HashSet<>( scopesToResolve ) );
+            this.aggregating = aggregating;
+
+            int hash = 17;
+            hash = hash * 31 + Objects.hashCode( groupId );
+            hash = hash * 31 + Objects.hashCode( artifactId );
+            hash = hash * 31 + Objects.hashCode( version );
+            hash = hash * 31 + Objects.hashCode( dependencyArtifacts );
+            hash = hash * 31 + Objects.hashCode( workspace );
+            hash = hash * 31 + Objects.hashCode( localRepo );
+            hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories );
+            hash = hash * 31 + Objects.hashCode( collect );
+            hash = hash * 31 + Objects.hashCode( resolve );
+            hash = hash * 31 + Objects.hashCode( aggregating );
+            this.hashCode = hash;
+        }
+
+        @Override
+        public String toString()
+        {
+            return groupId + ":" + artifactId + ":" + version;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return hashCode;
+        }
+
+        @Override
+        public boolean equals( Object o )
+        {
+            if ( o == this )
+            {
+                return true;
+            }
+
+            if ( !( o instanceof CacheKey ) )
+            {
+                return false;
+            }
+
+            CacheKey that = (CacheKey) o;
+
+            return Objects.equals( groupId, that.groupId ) && Objects.equals( artifactId, that.artifactId )
+                && Objects.equals( version, that.version )
+                && Objects.equals( dependencyArtifacts, that.dependencyArtifacts )
+                && Objects.equals( workspace, that.workspace ) 
+                && Objects.equals( localRepo, that.localRepo )
+                && RepositoryUtils.repositoriesEquals( repositories, that.repositories )
+                && Objects.equals( collect, that.collect ) 
+                && Objects.equals( resolve, that.resolve )
+                && aggregating == that.aggregating;
+        }
+    }
+
+    protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<>();
+
+    @Override
+    public Key createKey( MavenProject project, Collection<String> scopesToCollect,
+        Collection<String> scopesToResolve, boolean aggregating, RepositorySystemSession session )
+    {
+        return new CacheKey( project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve, 
+            aggregating, session );
+    }
+
+    @Override
+    public CacheRecord get( Key key )
+        throws LifecycleExecutionException
+    {
+        CacheRecord cacheRecord = cache.get( key );
+
+        if ( cacheRecord != null && cacheRecord.exception != null )
+        {
+            throw cacheRecord.exception;
+        }
+
+        return cacheRecord;
+    }
+
+    @Override
+    public CacheRecord put( Key key, Set<Artifact> projectArtifacts )
+    {
+        Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" );
+
+        assertUniqueKey( key );
+
+        CacheRecord record =
+            new CacheRecord( Collections.unmodifiableSet( new HashSet<>( projectArtifacts ) ) );
+
+        cache.put( key, record );
+
+        return record;
+    }
+
+    protected void assertUniqueKey( Key key )
+    {
+        if ( cache.containsKey( key ) )
+        {
+            throw new IllegalStateException( "Duplicate artifact resolution result for project " + key );
+        }
+    }
+
+    @Override
+    public CacheRecord put( Key key, LifecycleExecutionException exception )
+    {
+        Validate.notNull( exception, "exception cannot be null" );
+
+        assertUniqueKey( key );
+
+        CacheRecord record = new CacheRecord( exception );
+
+        cache.put( key, record );
+
+        return record;
+    }
+
+    @Override
+    public void flush()
+    {
+        cache.clear();
+    }
+
+    @Override
+    public void register( MavenProject project, Key cacheKey, CacheRecord record )
+    {
+        // default cache does not track record usage
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactsCache.java
new file mode 100644
index 0000000..ac093e9
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactsCache.java
@@ -0,0 +1,90 @@
+package org.apache.maven.project.artifact;
+
+/*
+ * 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.Collection;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.lifecycle.LifecycleExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.aether.RepositorySystemSession;
+/**
+ * Caches project artifacts. <strong>Warning:</strong> This is an internal utility interface that is only public for
+ * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without
+ * prior notice.
+ *
+ * @author Igor Fedorenko
+ * @author Benjamin Bentmann
+ * @author Anton Tanasenko
+ */
+public interface ProjectArtifactsCache
+{
+
+    /**
+     * A cache key.
+     */
+    interface Key
+    {
+        // marker interface for cache keys
+    }
+
+    static class CacheRecord
+    {
+
+        public final Set<Artifact> artifacts;
+
+        public final LifecycleExecutionException exception;
+
+        public CacheRecord( Set<Artifact> artifacts )
+        {
+            this.artifacts = artifacts;
+            this.exception = null;
+        }
+
+        public CacheRecord( LifecycleExecutionException exception )
+        {
+            this.artifacts = null;
+            this.exception = exception;
+        }
+    }
+
+    Key createKey( MavenProject project, Collection<String> scopesToCollect, Collection<String> scopesToResolve, 
+        boolean aggregating, RepositorySystemSession session );
+
+    CacheRecord get( Key key ) throws LifecycleExecutionException;
+
+    CacheRecord put( Key key, Set<Artifact> pluginArtifacts );
+
+    CacheRecord put( Key key, LifecycleExecutionException e );
+
+    void flush();
+
+    /**
+     * Registers the specified cache record for usage with the given project. Integrators can use the information
+     * collected from this method in combination with a custom cache implementation to dispose unused records from the
+     * cache.
+     *
+     * @param project The project that employs the plugin realm, must not be {@code null}.
+     * @param record The cache record being used for the project, must not be {@code null}.
+     */
+    void register( MavenProject project, Key cacheKey, CacheRecord record );
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
index 157a5ec..315e152 100644
--- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
@@ -20,6 +20,7 @@ package org.apache.maven;
  */
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
@@ -128,6 +129,12 @@ public abstract class AbstractCoreMavenComponentTestCase
     }
 
     protected MavenSession createMavenSession( File pom, Properties executionProperties )
+                    throws Exception
+    {
+        return createMavenSession( pom, executionProperties, false );
+    }
+    
+    protected MavenSession createMavenSession( File pom, Properties executionProperties, boolean includeModules )
         throws Exception
     {
         MavenExecutionRequest request = createMavenExecutionRequest( pom );
@@ -138,17 +145,32 @@ public abstract class AbstractCoreMavenComponentTestCase
             .setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
             .setSystemProperties( executionProperties );
 
-        MavenProject project = null;
+        List<MavenProject> projects = new ArrayList<>();
 
         if ( pom != null )
         {
-            project = projectBuilder.build( pom, configuration ).getProject();
+            MavenProject project = projectBuilder.build( pom, configuration ).getProject();
+            
+            projects.add( project );
+            if ( includeModules )
+            {
+                for( String module : project.getModules() )
+                {
+                    File modulePom = new File( pom.getParentFile(), module );
+                    if( modulePom.isDirectory() )
+                    {
+                        modulePom = new File( modulePom, "pom.xml" );
+                    }
+                    projects.add( projectBuilder.build( modulePom, configuration ).getProject() );
+                }
+            }
         }
         else
         {
-            project = createStubMavenProject();
+            MavenProject project = createStubMavenProject();
             project.setRemoteArtifactRepositories( request.getRemoteRepositories() );
             project.setPluginArtifactRepositories( request.getPluginArtifactRepositories() );
+            projects.add( project );
         }
 
         initRepoSession( configuration );
@@ -156,7 +178,7 @@ public abstract class AbstractCoreMavenComponentTestCase
         MavenSession session =
             new MavenSession( getContainer(), configuration.getRepositorySession(), request,
                               new DefaultMavenExecutionResult() );
-        session.setProjects( Arrays.asList( project ) );
+        session.setProjects( projects );
         session.setAllProjects( session.getProjects() );
 
         return session;

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolverTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolverTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolverTest.java
new file mode 100644
index 0000000..b38742a
--- /dev/null
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolverTest.java
@@ -0,0 +1,90 @@
+package org.apache.maven.lifecycle.internal;
+
+/*
+ * 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.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.maven.AbstractCoreMavenComponentTestCase;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.junit.Test;
+
+public class LifecycleDependencyResolverTest extends AbstractCoreMavenComponentTestCase
+{
+    @Requirement
+    private LifecycleDependencyResolver resolver;
+
+    @Override
+    protected String getProjectsDirectory()
+    {
+        return null;
+    }
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        resolver = lookup( LifecycleDependencyResolver.class );
+    }
+
+    @Test
+    public void testCachedReactorProjectDependencies() throws Exception
+    {
+        MavenSession session = createMavenSession( new File( "src/test/projects/lifecycle-dependency-resolver/pom.xml" ), new Properties(), true );
+        Collection<String> scopesToCollect = null;
+        Collection<String> scopesToResolve = Collections.singletonList( "compile" );
+        boolean aggregating = false;
+
+        Set<Artifact> reactorArtifacts = new HashSet<>( 3 );
+        for ( MavenProject reactorProject : session.getProjects() )
+        {
+            reactorProject.setArtifactFilter( new ArtifactFilter()
+            {
+                @Override
+                public boolean include( Artifact artifact )
+                {
+                    return true;
+                }
+            } );
+            resolver.resolveProjectDependencies( reactorProject, scopesToCollect, scopesToResolve, session, aggregating, reactorArtifacts );
+            reactorArtifacts.add( reactorProject.getArtifact() );
+        }
+
+        MavenProject lib = session.getProjects().get( 1 );
+        MavenProject war = session.getProjects().get( 2 );
+
+        assertEquals( null , war.getArtifactMap().get("org.apache.maven.its.mng6300:mng6300-lib").getFile() );
+
+        lib.getArtifact().setFile( new File( "lib.jar" ) );
+
+        resolver.resolveProjectDependencies( war, scopesToCollect, scopesToResolve, session, aggregating, reactorArtifacts );
+
+        assertEquals( new File( "lib.jar" ) , war.getArtifactMap().get("org.apache.maven.its.mng6300:mng6300-lib").getFile() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/test/projects/lifecycle-dependency-resolver/lib/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/projects/lifecycle-dependency-resolver/lib/pom.xml b/maven-core/src/test/projects/lifecycle-dependency-resolver/lib/pom.xml
new file mode 100644
index 0000000..e020408
--- /dev/null
+++ b/maven-core/src/test/projects/lifecycle-dependency-resolver/lib/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng6300</groupId>
+    <artifactId>test</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>mng6300-lib</artifactId>
+
+</project>

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/test/projects/lifecycle-dependency-resolver/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/projects/lifecycle-dependency-resolver/pom.xml b/maven-core/src/test/projects/lifecycle-dependency-resolver/pom.xml
new file mode 100644
index 0000000..8c7cfec
--- /dev/null
+++ b/maven-core/src/test/projects/lifecycle-dependency-resolver/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng6300</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-6300</name>
+  <description>
+    Check that war packages the jar instead of a directory
+  </description>
+  
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <reportSets>
+          <reportSet>
+            <reports>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+  
+  <modules>
+    <module>lib</module>
+    <module>war</module>
+  </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/maven/blob/98af937b/maven-core/src/test/projects/lifecycle-dependency-resolver/war/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/projects/lifecycle-dependency-resolver/war/pom.xml b/maven-core/src/test/projects/lifecycle-dependency-resolver/war/pom.xml
new file mode 100644
index 0000000..e168833
--- /dev/null
+++ b/maven-core/src/test/projects/lifecycle-dependency-resolver/war/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng6300</groupId>
+    <artifactId>test</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>mng6300-war</artifactId>
+  <packaging>war</packaging>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <configuration>
+          <failOnMissingWebXml>false</failOnMissingWebXml>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.mng6300</groupId>
+      <artifactId>mng6300-lib</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+
+</project>