You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by si...@apache.org on 2008/09/09 03:04:21 UTC

svn commit: r693332 [3/6] - in /maven/components/trunk: ./ maven-core-it-runner/ maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/errors/ maven-core/src/main/java/org/apache/maven/execution/ maven-core/src/main/java/...

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=693332&r1=693331&r2=693332&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Mon Sep  8 18:04:17 2008
@@ -21,36 +21,23 @@
 
 import org.apache.maven.MavenTools;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.ArtifactStatus;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.ManagedVersionMap;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Exclusion;
-import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginManagement;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.ReportPlugin;
-import org.apache.maven.model.Repository;
-import org.apache.maven.model.Resource;
+import org.apache.maven.model.Profile;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.profiles.MavenProfilesBuilder;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
@@ -58,32 +45,37 @@
 import org.apache.maven.profiles.activation.ProfileActivationException;
 import org.apache.maven.profiles.build.ProfileAdvisor;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.build.model.DefaultModelLineage;
-import org.apache.maven.project.build.model.ModelLineage;
-import org.apache.maven.project.build.model.ModelLineageBuilder;
-import org.apache.maven.project.build.model.ModelLineageIterator;
-import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
-import org.apache.maven.project.injection.ModelDefaultsInjector;
+import org.apache.maven.project.builder.PomArtifactResolver;
+import org.apache.maven.project.builder.ProjectBuilder;
 import org.apache.maven.project.interpolation.ModelInterpolationException;
 import org.apache.maven.project.interpolation.ModelInterpolator;
 import org.apache.maven.project.path.PathTranslator;
 import org.apache.maven.project.validation.ModelValidationResult;
 import org.apache.maven.project.validation.ModelValidator;
 import org.apache.maven.project.workspace.ProjectWorkspace;
-import org.apache.maven.project.builder.PomArtifactResolver;
-import org.apache.maven.project.builder.ProjectBuilder;
-import org.apache.maven.project.builder.PomClassicDomainModel;
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.WriterFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
 import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 
 /*:apt
 
@@ -123,10 +115,9 @@
  * @version $Id$
  */
 public class DefaultMavenProjectBuilder
-    implements MavenProjectBuilder,
-    Initializable, LogEnabled
+    implements MavenProjectBuilder, Initializable, LogEnabled
 {
-    protected MavenProfilesBuilder profilesBuilder;                        
+    protected MavenProfilesBuilder profilesBuilder;
 
     protected ArtifactResolver artifactResolver;
 
@@ -134,8 +125,6 @@
 
     private ArtifactFactory artifactFactory;
 
-    private ModelInheritanceAssembler modelInheritanceAssembler;
-
     private ModelValidator validator;
 
     // TODO: make it a component
@@ -143,12 +132,8 @@
 
     private PathTranslator pathTranslator;
 
-    private ModelDefaultsInjector modelDefaultsInjector;
-
     private ModelInterpolator modelInterpolator;
 
-    private ModelLineageBuilder modelLineageBuilder;
-
     private ProfileAdvisor profileAdvisor;
 
     private MavenTools mavenTools;
@@ -157,14 +142,18 @@
 
     private ProjectBuilder projectBuilder;
 
+    private RepositoryHelper repositoryHelper;
+
+    private Logger logger;
+
     //DO NOT USE, it is here only for backward compatibility reasons. The existing
     // maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
 
-// the aspect weaving seems not to work for reflection from plugin.
-    private Map processedProjectCache = new HashMap();
+    // the aspect weaving seems not to work for reflection from plugin.
 
+    private Map processedProjectCache = new HashMap();
 
-    public static final String MAVEN_MODEL_VERSION = "4.0.0";
+    private static final String MAVEN_MODEL_VERSION = "4.0.0";
 
     public void initialize()
     {
@@ -175,30 +164,52 @@
     // MavenProjectBuilder Implementation
     // ----------------------------------------------------------------------
 
-    public MavenProject build( File projectDescriptor,
-                               ArtifactRepository localRepository,
+    public MavenProject build( File projectDescriptor, ArtifactRepository localRepository,
                                ProfileManager profileManager )
         throws ProjectBuildingException
     {
-        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
-                                                                                     .setGlobalProfileManager( profileManager );
+        ProjectBuilderConfiguration config =
+            new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
+                .setGlobalProfileManager( profileManager );
 
-        return buildFromSourceFileInternal( projectDescriptor, config );
+        return build( projectDescriptor, config );
     }
 
-    public MavenProject build( File projectDescriptor,
-                               ProjectBuilderConfiguration config )
+    public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
         throws ProjectBuildingException
     {
-        return buildFromSourceFileInternal( projectDescriptor, config );
+        MavenProject project = projectWorkspace.getProject( projectDescriptor );
+
+        if ( project == null )
+        {
+            project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
+                config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
+                getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
+
+            project.setFile( projectDescriptor );
+            project = buildInternal( project.getModel(), config, projectDescriptor, project.getParentFile(), true );
+
+            Build build = project.getBuild();
+            // NOTE: setting this script-source root before path translation, because
+            // the plugin tools compose basedir and scriptSourceRoot into a single file.
+            project.addScriptSourceRoot( build.getScriptSourceDirectory() );
+            project.addCompileSourceRoot( build.getSourceDirectory() );
+            project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
+            project.setFile( projectDescriptor );
+
+            setBuildOutputDirectoryOnParent( project );
+
+        }
+        return project;
     }
 
-    /** @deprecated  */
+
+    /**
+     * @deprecated
+     */
     @Deprecated
-    public MavenProject buildFromRepository( Artifact artifact,
-                                             List remoteArtifactRepositories,
-                                             ArtifactRepository localRepository,
-                                             boolean allowStub )
+    public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
+                                             ArtifactRepository localRepository, boolean allowStub )
         throws ProjectBuildingException
 
     {
@@ -206,41 +217,41 @@
     }
 
 
-    public MavenProject buildFromRepository( Artifact artifact,
-                                             List remoteArtifactRepositories,
+    public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
                                              ArtifactRepository localRepository )
         throws ProjectBuildingException
     {
-        String artifactKey = artifact.getId();
-
         MavenProject project = null;
-        if ( !Artifact.LATEST_VERSION.equals( artifact.getVersion() ) && !Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) )
+        if ( !Artifact.LATEST_VERSION.equals( artifact.getVersion() ) &&
+            !Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) )
         {
-//            getLogger().debug( "Checking cache for project (in buildFromRepository): " + artifactKey );
-            project = projectWorkspace.getProject( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
+            project =
+                projectWorkspace.getProject( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
         }
-
+        File f = artifact.getFile();
         if ( project == null )
         {
-//            getLogger().debug( "Allowing buildFromRepository to proceed for: " + artifactKey );
+            repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
 
-            Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
+            ProjectBuilderConfiguration config =
+                new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
 
-            ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
+            List<ArtifactRepository> artifactRepositories =
+                new ArrayList<ArtifactRepository>( remoteArtifactRepositories );
+            artifactRepositories.addAll( repositoryHelper.buildArtifactRepositories(
+                getSuperProject( config, artifact.getFile(), false ).getModel() ) );
 
-            project = buildInternal( model, config, remoteArtifactRepositories, artifact.getFile(),
-                                  false, false, false );
+            project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver(
+                config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
+            project = buildInternal( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
         }
-//        else
-//        {
-//            getLogger().debug( "Returning cached project: " + project );
-//        }
+
+        artifact.setFile( f );
+        project.setVersion( artifact.getVersion() );
 
         return project;
     }
 
-    private Logger logger;
-
     // what is using this externally? jvz.
     public MavenProject buildStandaloneSuperProject()
         throws ProjectBuildingException
@@ -253,7 +264,8 @@
         throws ProjectBuildingException
     {
         //TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable
-        return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration().setGlobalProfileManager( profileManager ) );
+        return buildStandaloneSuperProject(
+            new DefaultProjectBuilderConfiguration().setGlobalProfileManager( profileManager ) );
     }
 
     public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
@@ -274,7 +286,8 @@
         List activeProfiles = new ArrayList();
         if ( profileManager != null )
         {
-            List activated = profileAdvisor.applyActivatedProfiles( superModel, null, false, profileManager.getProfileActivationContext() );
+            List activated = profileAdvisor.applyActivatedProfiles( superModel, null, false,
+                                                                    profileManager.getProfileActivationContext() );
             if ( !activated.isEmpty() )
             {
                 activeProfiles.addAll( activated );
@@ -287,112 +300,92 @@
             }
         }
 
-        MavenProject project = new MavenProject( superModel );
-
-        String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
-
-        project.setManagedVersionMap(
-            createManagedVersionMap( projectId, superModel.getDependencyManagement(), null ) );
+        MavenProject project;
+        try
+        {
+            project = new MavenProject( superModel, artifactFactory, mavenTools, repositoryHelper, this, config );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":" + STANDALONE_SUPERPOM_ARTIFACTID,
+                                                "Maven super-POM contains an invalid repository!", e );
+        }
 
         getLogger().debug( "Activated the following profiles for standalone super-pom: " + activeProfiles );
-        project.setActiveProfiles( activeProfiles );
-
 
         try
         {
-            processProjectLogic( project, null, config, null, true, true );
-
-            project.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
-            project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
+            project = interpolateModelAndInjectDefault( project.getModel(), null, null, config );
+            project.setActiveProfiles( activeProfiles );
+            project.setRemoteArtifactRepositories(
+                mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
+            project.setPluginArtifactRepositories(
+                mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
         }
         catch ( InvalidRepositoryException e )
         {
-            // we shouldn't be swallowing exceptions, no matter how unlikely.
-            // or, if we do, we should pay attention to the one coming from getSuperModel()...
-            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
-                                             + STANDALONE_SUPERPOM_ARTIFACTID,
-                                                "Maven super-POM contains an invalid repository!",
-                                                e );
+            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":" + STANDALONE_SUPERPOM_ARTIFACTID,
+                                                "Maven super-POM contains an invalid repository!", e );
         }
         catch ( ModelInterpolationException e )
         {
-            // we shouldn't be swallowing exceptions, no matter how unlikely.
-            // or, if we do, we should pay attention to the one coming from getSuperModel()...
-            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
-                                             + STANDALONE_SUPERPOM_ARTIFACTID,
-                                                "Maven super-POM contains an invalid expressions!",
-                                                e );
+            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":" + STANDALONE_SUPERPOM_ARTIFACTID,
+                                                "Maven super-POM contains an invalid expressions!", e );
         }
 
-        project.setOriginalModel( superModel );
-
         project.setExecutionRoot( true );
 
         return project;
     }
 
-    /** @since 2.0.x */
-    public MavenProject buildWithDependencies( File projectDescriptor,
-                                               ArtifactRepository localRepository,
+    /**
+     * @since 2.0.x
+     */
+    public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
                                                ProfileManager profileManager )
         throws ProjectBuildingException
     {
         return buildProjectWithDependencies( projectDescriptor, localRepository, profileManager ).getProject();
     }
 
-    /** @since 2.1 */
+    /**
+     * @since 2.1
+     */
     public MavenProjectBuildingResult buildProjectWithDependencies( File projectDescriptor,
-                                                             ArtifactRepository localRepository,
-                                                             ProfileManager profileManager )
+                                                                    ArtifactRepository localRepository,
+                                                                    ProfileManager profileManager )
         throws ProjectBuildingException
     {
-        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
-                                                                                     .setGlobalProfileManager( profileManager );
+        ProjectBuilderConfiguration config =
+            new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
+                .setGlobalProfileManager( profileManager );
 
         return buildProjectWithDependencies( projectDescriptor, config );
     }
 
     public MavenProjectBuildingResult buildProjectWithDependencies( File projectDescriptor,
                                                                     ProjectBuilderConfiguration config )
-               throws ProjectBuildingException
-   {
+        throws ProjectBuildingException
+    {
         MavenProject project = build( projectDescriptor, config );
 
-        // ----------------------------------------------------------------------
-        // Typically when the project builder is being used from maven proper
-        // the transitive dependencies will not be resolved here because this
-        // requires a lot of work when we may only be interested in running
-        // something simple like 'm2 clean'. So the artifact collector is used
-        // in the dependency resolution phase if it is required by any of the
-        // goals being executed. But when used as a component in another piece
-        // of code people may just want to build maven projects and have the
-        // dependencies resolved for whatever reason: this is why we keep
-        // this snippet of code here.
-        // ----------------------------------------------------------------------
-
-        Artifact projectArtifact = project.getArtifact();
-
-        String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
-
-        Map managedVersions = project.getManagedVersionMap();
-
         try
         {
             project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
         }
         catch ( InvalidDependencyVersionException e )
         {
-            throw new ProjectBuildingException( projectId,
-                "Unable to build project due to an invalid dependency version: " +
-                    e.getMessage(), projectDescriptor, e );
+            throw new ProjectBuildingException( safeVersionlessKey( project.getGroupId(), project.getArtifactId() ),
+                                                "Unable to build project due to an invalid dependency version: " +
+                                                    e.getMessage(), projectDescriptor, e );
         }
 
         ArtifactResolutionRequest request = new ArtifactResolutionRequest()
-            .setArtifact( projectArtifact )
+            .setArtifact( project.getArtifact() )
             .setArtifactDependencies( project.getDependencyArtifacts() )
             .setLocalRepository( config.getLocalRepository() )
             .setRemoteRepostories( project.getRemoteArtifactRepositories() )
-            .setManagedVersionMap( managedVersions )
+            .setManagedVersionMap( project.getManagedVersionMap() )
             .setMetadataSource( artifactMetadataSource );
 
         ArtifactResolutionResult result = artifactResolver.resolve( request );
@@ -402,290 +395,195 @@
         return new MavenProjectBuildingResult( project, result );
     }
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private Map createManagedVersionMap( String projectId,
-                                         DependencyManagement dependencyManagement, File pomFile )
-        throws ProjectBuildingException
+    public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
     {
-        Map map = null;
-        List deps;
-        if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) )
-        {
-            map = new ManagedVersionMap( map );
-
-            if ( getLogger().isDebugEnabled() )
-            {
-                getLogger().debug( "Adding managed dependencies for " + projectId );
-            }
-
-            for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
-            {
-                Dependency d = (Dependency) i.next();
-
-                try
-                {
-                    VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
-
-                    Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(),
-                        d.getClassifier(), d.getScope(), d.isOptional() );
-
-                    if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && ( d.getSystemPath() != null ) )
-                    {
-                        artifact.setFile( new File( d.getSystemPath() ) );
-                    }
-
-                    if ( getLogger().isDebugEnabled() )
-                    {
-                        getLogger().debug( "  " + artifact );
-                    }
-
-                    // If the dependencyManagement section listed exclusions,
-                    // add them to the managed artifacts here so that transitive
-                    // dependencies will be excluded if necessary.
-
-                    if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
-                    {
-                        List exclusions = new ArrayList();
-
-                        for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
-                        {
-                            Exclusion e = (Exclusion) j.next();
-
-                            exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
-                        }
-
-                        ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
-
-                        artifact.setDependencyFilter( eaf );
-                    }
-                    else
-                    {
-                        artifact.setDependencyFilter( null );
-                    }
-
-                    map.put( d.getManagementKey(), artifact );
-                }
-                catch ( InvalidVersionSpecificationException e )
-                {
-                    throw new InvalidDependencyVersionException( projectId, d, pomFile, e );
-                }
-            }
-        }
-        else if ( map == null )
-        {
-            map = Collections.EMPTY_MAP;
-        }
-        return map;
+        new MavenProjectRestorer( pathTranslator, modelInterpolator, getLogger() ).calculateConcreteState( project,
+                                                                                                           config );
     }
 
-    private MavenProject buildFromSourceFileInternal( File projectDescriptor,
-                                                      ProjectBuilderConfiguration config )
-        throws ProjectBuildingException
+    public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
     {
-//        getLogger().debug( "Checking cache-hit on project (in build*): " + projectDescriptor );
+        new MavenProjectRestorer( pathTranslator, modelInterpolator, getLogger() ).restoreDynamicState( project,
+                                                                                                        config );
+    }
 
-        MavenProject project = projectWorkspace.getProject( projectDescriptor );
+    public void enableLogging( Logger logger )
+    {
+        this.logger = logger;
+    }
 
-        if ( project == null )
-        {
-            Model model = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(config.getLocalRepository(),
-                    buildArtifactRepositories( getSuperModel() ), artifactResolver) );
-            project = buildInternal(model,
-                config,
-                buildArtifactRepositories( getSuperModel() ),
-                projectDescriptor,
-                STRICT_MODEL_PARSING,
-                true,
-                true );
-        }
-        return project;
+    private Logger getLogger()
+    {
+        return logger;
     }
 
-    private Model findModelFromRepository( Artifact artifact,
-                                           List remoteArtifactRepositories,
-                                           ArtifactRepository localRepository )
+    private MavenProject buildInternal( Model model, ProjectBuilderConfiguration config, File projectDescriptor,
+                                        File parentDescriptor, boolean isReactorProject )
         throws ProjectBuildingException
     {
+        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
 
-        String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
-        remoteArtifactRepositories = normalizeToArtifactRepositories( remoteArtifactRepositories, projectId );
-
-        Artifact projectArtifact;
-
-        // if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given.
-        if ( "pom".equals( artifact.getType() ) )
+        ProfileActivationContext profileActivationContext;
+        ProfileManager externalProfileManager = config.getGlobalProfileManager();
+        if ( externalProfileManager != null )
         {
-            projectArtifact = artifact;
+            // used to trigger the caching of SystemProperties in the container context...
+            try
+            {
+                externalProfileManager.getActiveProfiles();
+            }
+            catch ( ProfileActivationException e )
+            {
+                throw new ProjectBuildingException( projectId, "Failed to activate external profiles.",
+                                                    projectDescriptor, e );
+            }
+            profileActivationContext = externalProfileManager.getProfileActivationContext();
         }
         else
         {
-            getLogger().warn( "Attempting to build MavenProject instance for Artifact (" + artifact.getGroupId() + ":"
-             + artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: "
-             + artifact.getType() + "; constructing POM artifact instead." );
-
-            projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(),
-                artifact.getArtifactId(),
-                artifact.getVersion(),
-                artifact.getScope() );
+            profileActivationContext = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
         }
 
-        Model legacy_model;
+        MavenProject project;
         try
         {
-            artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
-
-            File file = projectArtifact.getFile();
-
-            legacy_model = readModelLegacy( projectId, file, STRICT_MODEL_PARSING );
-
-            String downloadUrl = null;
-
-            ArtifactStatus status = ArtifactStatus.NONE;
-
-            DistributionManagement distributionManagement = legacy_model.getDistributionManagement();
+            project = interpolateModelAndInjectDefault( model, projectDescriptor, parentDescriptor, config );
+        }
+        catch ( ModelInterpolationException e )
+        {
+            throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor, e );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor, e );
+        }
 
-            if ( distributionManagement != null )
-            {
-                downloadUrl = distributionManagement.getDownloadUrl();
+        List<Profile> projectProfiles = new ArrayList<Profile>();
+        projectProfiles.addAll( profileAdvisor.applyActivatedProfiles( project.getModel(), project.getFile(),
+                                                                       isReactorProject, profileActivationContext ) );
+        projectProfiles.addAll( profileAdvisor.applyActivatedExternalProfiles( project.getModel(), project.getFile(),
+                                                                               externalProfileManager ) );
+        project.setActiveProfiles( projectProfiles );
 
-                status = ArtifactStatus.valueOf( distributionManagement.getStatus() );
-            }
+        projectWorkspace.storeProjectByCoordinate( project );
+        projectWorkspace.storeProjectByFile( project );
 
-            checkStatusAndUpdate( projectArtifact, status, file, remoteArtifactRepositories, localRepository );
+        return project;
+    }
 
-            // TODO: this is gross. Would like to give it the whole model, but maven-artifact shouldn't depend on that
-            // Can a maven-core implementation of the Artifact interface store it, and be used in the exceptions?
-            if ( downloadUrl != null )
-            {
-                projectArtifact.setDownloadUrl( downloadUrl );
-            }
-            else
-            {
-                projectArtifact.setDownloadUrl( legacy_model.getUrl() );
-            }
+    private MavenProject interpolateModelAndInjectDefault( Model model, File pomFile, File parentFile,
+                                                           ProjectBuilderConfiguration config )
+        throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
+    {
+        File projectDir = null;
+        if ( pomFile != null )
+        {
+            projectDir = pomFile.getAbsoluteFile().getParentFile();
         }
-        catch ( ArtifactResolutionException e )
+
+        Build dynamicBuild = model.getBuild();
+        if ( dynamicBuild != null )
         {
-            throw new ProjectBuildingException( projectId, "Error getting POM for '" + projectId + "' from the repository: " + e.getMessage(), e );
+            model.setBuild( ModelUtils.cloneBuild( dynamicBuild ) );
         }
-        catch ( ArtifactNotFoundException e )
+        model = modelInterpolator.interpolate( model, projectDir, config, getLogger().isDebugEnabled() );
+
+        if ( dynamicBuild != null && model.getBuild() != null )
         {
-            throw new ProjectBuildingException( projectId, "POM '" + projectId + "' not found in repository: " + e.getMessage(), e );
+            mergeDeterministicBuildElements( model.getBuild(), dynamicBuild );
+            model.setBuild( dynamicBuild );
         }
 
-        return legacy_model;
+        // interpolation is before injection, because interpolation is off-limits in the injected variables
+        new DefaultModelDefaultsInjector().injectDefaults( model );
+
+        // We will return a different project object using the new model (hence the need to return a project, not just modify the parameter)
+        MavenProject project = new MavenProject( model, artifactFactory, mavenTools, repositoryHelper, this, config );
+
+        Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
+                                                                        project.getVersion(), project.getPackaging() );
+        project.setArtifact( projectArtifact );
+        project.setParentFile( parentFile );
+
+        validateModel( model, pomFile );
+        return project;
     }
 
-    private List normalizeToArtifactRepositories( List remoteArtifactRepositories,
-                                                  String projectId )
-        throws ProjectBuildingException
+    // TODO: Remove this!
+    @SuppressWarnings("unchecked")
+    private void mergeDeterministicBuildElements( Build interpolatedBuild, Build dynamicBuild )
     {
-        List normalized = new ArrayList( remoteArtifactRepositories.size() );
+        List<Plugin> dPlugins = dynamicBuild.getPlugins();
 
-        boolean normalizationNeeded = false;
-        for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
+        if ( dPlugins != null )
         {
-            Object item = it.next();
+            List<Plugin> iPlugins = interpolatedBuild.getPlugins();
 
-            if ( item instanceof ArtifactRepository )
-            {
-                normalized.add( item );
-            }
-            else if ( item instanceof Repository )
+            for ( int i = 0; i < dPlugins.size(); i++ )
             {
-                Repository repo = (Repository) item;
-                try
-                {
-                    item = mavenTools.buildArtifactRepository( repo );
+                Plugin dPlugin = dPlugins.get( i );
+                Plugin iPlugin = iPlugins.get( i );
 
-                    normalized.add( item );
-                    normalizationNeeded = true;
-                }
-                catch ( InvalidRepositoryException e )
-                {
-                    throw new ProjectBuildingException( projectId, "Error building artifact repository for id: " + repo.getId(), e );
-                }
-            }
-            else
-            {
-                throw new ProjectBuildingException( projectId, "Error building artifact repository from non-repository information item: " + item );
+                dPlugin.setGroupId( iPlugin.getGroupId() );
+                dPlugin.setArtifactId( iPlugin.getArtifactId() );
+                dPlugin.setVersion( iPlugin.getVersion() );
+
+                dPlugin.setDependencies( iPlugin.getDependencies() );
             }
         }
 
-        if ( normalizationNeeded )
-        {
-            return normalized;
-        }
-        else
-        {
-            return remoteArtifactRepositories;
-        }
-    }
+        PluginManagement dPluginMgmt = dynamicBuild.getPluginManagement();
 
-    private void checkStatusAndUpdate( Artifact projectArtifact,
-                                       ArtifactStatus status,
-                                       File file,
-                                       List remoteArtifactRepositories,
-                                       ArtifactRepository localRepository )
-        throws ArtifactNotFoundException
-    {
-        // TODO: configurable actions dependant on status
-        if ( !projectArtifact.isSnapshot() && ( status.compareTo( ArtifactStatus.DEPLOYED ) < 0 ) )
+        if ( dPluginMgmt != null )
         {
-            // use default policy (enabled, daily update, warn on bad checksum)
-            ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
-            // TODO: re-enable [MNG-798/865]
-            policy.setUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
-
-            if ( policy.checkOutOfDate( new Date( file.lastModified() ) ) )
+            PluginManagement iPluginMgmt = interpolatedBuild.getPluginManagement();
+            dPlugins = dPluginMgmt.getPlugins();
+            if ( dPlugins != null )
             {
-                getLogger().info(
-                    projectArtifact.getArtifactId() + ": updating metadata due to status of '" + status + "'" );
-                try
-                {
-                    projectArtifact.setResolved( false );
-                    artifactResolver.resolveAlways( projectArtifact, remoteArtifactRepositories, localRepository );
-                }
-                catch ( ArtifactResolutionException e )
-                {
-                    getLogger().warn( "Error updating POM - using existing version" );
-                    getLogger().debug( "Cause", e );
-                }
-                catch ( ArtifactNotFoundException e )
+                List<Plugin> iPlugins = iPluginMgmt.getPlugins();
+
+                for ( int i = 0; i < dPlugins.size(); i++ )
                 {
-                    getLogger().warn( "Error updating POM - not found. Removing local copy." );
-                    getLogger().debug( "Cause", e );
-                    file.delete();
-                    throw e;
+                    Plugin dPlugin = dPlugins.get( i );
+                    Plugin iPlugin = iPlugins.get( i );
+
+                    dPlugin.setGroupId( iPlugin.getGroupId() );
+                    dPlugin.setArtifactId( iPlugin.getArtifactId() );
+                    dPlugin.setVersion( iPlugin.getVersion() );
+
+                    dPlugin.setDependencies( iPlugin.getDependencies() );
                 }
             }
         }
+
+        if ( dynamicBuild.getExtensions() != null )
+        {
+            dynamicBuild.setExtensions( interpolatedBuild.getExtensions() );
+        }
     }
 
-    // jvz:note
-    // We've got a mixture of things going in the USD and from the repository, sometimes the descriptor
-    // is a real file and sometimes null which makes things confusing.
-    private MavenProject buildInternal( Model model,
-                                        ProjectBuilderConfiguration config,
-                                        List parentSearchRepositories,
-                                        File projectDescriptor,
-                                        boolean strict,
-                                        boolean isReactorProject,
-                                        boolean fromSourceTree )
+    private MavenProject getSuperProject( ProjectBuilderConfiguration config, File projectDescriptor,
+                                          boolean isReactorProject )
         throws ProjectBuildingException
     {
-        Model superModel = getSuperModel();
 
-        MavenProject superProject = new MavenProject( superModel );
+        MavenProject superProject;
+        Model model = getSuperModel();
+        try
+        {
+            superProject = new MavenProject( model, artifactFactory, mavenTools, repositoryHelper, this, config );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":" + STANDALONE_SUPERPOM_ARTIFACTID,
+                                                "Maven super-POM contains an invalid repository!", e );
+        }
 
         String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
 
-        // FIXME: Find a way to pass in this context, so it's never null!
         ProfileActivationContext profileActivationContext;
-
         ProfileManager externalProfileManager = config.getGlobalProfileManager();
         if ( externalProfileManager != null )
         {
@@ -696,9 +594,9 @@
             }
             catch ( ProfileActivationException e )
             {
-                throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor, e );
+                throw new ProjectBuildingException( projectId, "Failed to activate external profiles.",
+                                                    projectDescriptor, e );
             }
-
             profileActivationContext = externalProfileManager.getProfileActivationContext();
         }
         else
@@ -706,197 +604,123 @@
             profileActivationContext = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
         }
 
-        LinkedHashSet activeInSuperPom = new LinkedHashSet();
-        List activated = profileAdvisor.applyActivatedProfiles( superModel, projectDescriptor, isReactorProject, profileActivationContext );
-        if ( !activated.isEmpty() )
-        {
-            activeInSuperPom.addAll( activated );
-        }
+        List<Profile> superProjectProfiles = new ArrayList<Profile>();
+        superProjectProfiles.addAll( profileAdvisor.applyActivatedProfiles( model, projectDescriptor, isReactorProject,
+                                                                            profileActivationContext ) );
+        superProjectProfiles.addAll(
+            profileAdvisor.applyActivatedExternalProfiles( model, projectDescriptor, externalProfileManager ) );
+        superProject.setActiveProfiles( superProjectProfiles );
+
+        return superProject;
+    }
 
-        activated = profileAdvisor.applyActivatedExternalProfiles( superModel, projectDescriptor, externalProfileManager );
-        if ( !activated.isEmpty() )
+    private Model superModel;
+
+    private Model getSuperModel()
+        throws ProjectBuildingException
+    {
+        if ( superModel != null )
         {
-            activeInSuperPom.addAll( activated );
+            return superModel;
         }
 
-        superProject.setActiveProfiles( activated );
-
-        //noinspection CollectionDeclaredAsConcreteClass
-        LinkedList lineage = new LinkedList();
-
-        LinkedHashSet aggregatedRemoteWagonRepositories = collectInitialRepositories( model, superModel,
-            parentSearchRepositories,
-            projectDescriptor,
-            isReactorProject,
-            profileActivationContext );
-
-        Model originalModel = ModelUtils.cloneModel( model );
-
-        MavenProject project;
+        URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
+        String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
 
+        Reader reader = null;
         try
         {
-            project = assembleLineage( model, lineage, config, projectDescriptor, aggregatedRemoteWagonRepositories, strict, isReactorProject );
-        }
-        catch ( InvalidRepositoryException e )
-        {
-            throw new ProjectBuildingException( projectId, e.getMessage(), e );
-        }
-
-        project.setOriginalModel( originalModel );
-
-        // we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
-        MavenProject previousProject = superProject;
-
-        Model previous = superProject.getModel();
-
-        for ( Iterator i = lineage.iterator(); i.hasNext(); )
-        {
-            MavenProject currentProject = (MavenProject) i.next();
-
-            Model current = currentProject.getModel();
-
-            String pathAdjustment = null;
-
-            try
-            {
-                pathAdjustment = previousProject.getModulePathAdjustment( currentProject );
-            }
-            catch ( IOException e )
-            {
-                getLogger().debug(
-                    "Cannot determine whether " + currentProject.getId() + " is a module of " + previousProject.getId() + ". Reason: " + e.getMessage(),
-                    e );
-            }
-
-            modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment );
-
-            previous = current;
-            previousProject = currentProject;
-        }
-
-        // only add the super repository if it wasn't overridden by a profile or project
-        List repositories = new ArrayList( aggregatedRemoteWagonRepositories );
-
-        List superRepositories = buildArtifactRepositories( superModel );
-
-        for ( Iterator i = superRepositories.iterator(); i.hasNext(); )
-        {
-            ArtifactRepository repository = (ArtifactRepository) i.next();
+            reader = ReaderFactory.newXmlReader( url.openStream() );
+            String modelSource = IOUtil.toString( reader );
 
-            if ( !repositories.contains( repository ) )
+            if ( modelSource.indexOf( "<modelVersion>" + MAVEN_MODEL_VERSION ) < 0 )
             {
-                repositories.add( repository );
+                throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.",
+                                                        new File( "." ) );
             }
-        }
 
-        // merge any duplicated plugin definitions together, using the first appearance as the dominant one.
-        ModelUtils.mergeDuplicatePluginDefinitions( project.getModel().getBuild() );
+            StringReader sReader = new StringReader( modelSource );
 
-        try
-        {
-            project = processProjectLogic( project, projectDescriptor, config, repositories, strict, false );
+            superModel = modelReader.read( sReader, STRICT_MODEL_PARSING );
+            return superModel;
         }
-        catch ( ModelInterpolationException e )
+        catch ( XmlPullParserException e )
         {
-            throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor, e );
+            throw new InvalidProjectModelException( projectId, "Parse error reading POM. Reason: " + e.getMessage(),
+                                                    e );
         }
-        catch ( InvalidRepositoryException e )
+        catch ( IOException e )
         {
-            throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor, e );
+            throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
+                "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
-
-        if ( fromSourceTree )
+        finally
         {
-            Build build = project.getBuild();
-
-            // NOTE: setting this script-source root before path translation, because
-            // the plugin tools compose basedir and scriptSourceRoot into a single file.
-            project.addScriptSourceRoot( build.getScriptSourceDirectory() );
-
-            project.addCompileSourceRoot( build.getSourceDirectory() );
-
-            project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
-
-            // Only track the file of a POM in the source tree
-            project.setFile( projectDescriptor );
+            IOUtil.close( reader );
         }
-
-//        getLogger().debug( "Caching project: " + project.getId() + " (also keyed by file: " + project.getFile() + ")" );
-
-
-        projectWorkspace.storeProjectByCoordinate( project );
-        projectWorkspace.storeProjectByFile( project );
-
-        project.setManagedVersionMap( createManagedVersionMap( projectId, project.getDependencyManagement(), projectDescriptor ) );
-
-        return project;
     }
 
-    /*
-     * Order is:
-     *
-     * 1. model profile repositories
-     * 2. model repositories
-     * 3. superModel profile repositories
-     * 4. superModel repositories
-     * 5. parentSearchRepositories
-     */
-    private LinkedHashSet collectInitialRepositories( Model model,
-                                                      Model superModel,
-                                                      List parentSearchRepositories,
-                                                      File pomFile,
-                                                      boolean validProfilesXmlLocation,
-                                                      ProfileActivationContext profileActivationContext )
+    private MavenProject readModelFromLocalPath( String projectId, File projectDescriptor, PomArtifactResolver resolver,
+                                                 ProjectBuilderConfiguration config )
         throws ProjectBuildingException
     {
-        LinkedHashSet collected = new LinkedHashSet();
-
-        collectInitialRepositoriesFromModel( collected, model, pomFile, validProfilesXmlLocation, profileActivationContext );
+        if ( projectDescriptor == null )
+        {
+            throw new IllegalArgumentException( "projectDescriptor: null, Project Id =" + projectId );
+        }
 
-        collectInitialRepositoriesFromModel( collected, superModel, null, validProfilesXmlLocation, profileActivationContext );
+        if ( projectBuilder == null )
+        {
+            throw new IllegalArgumentException( "projectBuilder: not initialized" );
+        }
 
-        if ( ( parentSearchRepositories != null ) && !parentSearchRepositories.isEmpty() )
+        MavenProject mavenProject;
+        try
         {
-            collected.addAll( parentSearchRepositories );
+            mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ), Arrays.asList(
+                getSuperProject( config, projectDescriptor, true ).getModel() ), null, null, resolver,
+                                                                                 projectDescriptor.getParentFile(),
+                                                                                 config );
         }
+        catch ( IOException e )
+        {
+            throw new ProjectBuildingException( projectId, "File = " + projectDescriptor.getAbsolutePath(), e );
+        }
+
+        return mavenProject;
 
-        return collected;
     }
 
-    private void collectInitialRepositoriesFromModel( LinkedHashSet collected,
-                                                      Model model,
-                                                      File pomFile,
-                                                      boolean validProfilesXmlLocation,
-                                                      ProfileActivationContext profileActivationContext )
-        throws ProjectBuildingException
+    private void validateModel( Model model, File pomFile )
+        throws InvalidProjectModelException
     {
-        Set reposFromProfiles = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, pomFile, validProfilesXmlLocation, profileActivationContext );
-
-        if ( ( reposFromProfiles != null ) && !reposFromProfiles.isEmpty() )
-        {
-            collected.addAll( reposFromProfiles );
-        }
+        // Must validate before artifact construction to make sure dependencies are good
+        ModelValidationResult validationResult = validator.validate( model );
 
-        List modelRepos = model.getRepositories();
+        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
 
-        if ( ( modelRepos != null ) && !modelRepos.isEmpty() )
+        if ( validationResult.getMessageCount() > 0 )
         {
+            for ( String s : (List<String>) validationResult.getMessages() )
+            {
+                System.out.println( s );
+            }
             try
             {
-                collected.addAll( mavenTools.buildArtifactRepositories( modelRepos ) );
+                Writer out = WriterFactory.newXmlWriter( System.out );
+                MavenXpp3Writer writer = new MavenXpp3Writer();
+                writer.write( out, model );
+                out.close();
             }
-            catch ( InvalidRepositoryException e )
+            catch ( IOException e )
             {
-                throw new ProjectBuildingException( safeVersionlessKey( model.getGroupId(), model.getArtifactId() ),
-                    "Failed to construct ArtifactRepository instances for repositories declared in: " +
-                     model.getId(), e );
+
             }
+            throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomFile, validationResult );
         }
     }
 
-    private String safeVersionlessKey( String groupId,
-                                       String artifactId )
+    private static String safeVersionlessKey( String groupId, String artifactId )
     {
         String gid = groupId;
 
@@ -915,1185 +739,118 @@
         return ArtifactUtils.versionlessKey( gid, aid );
     }
 
-    private List buildArtifactRepositories( Model model )
-        throws ProjectBuildingException
+    private static void setBuildOutputDirectoryOnParent( MavenProject project )
     {
-        try
-        {
-            return mavenTools.buildArtifactRepositories( model.getRepositories() );
-        }
-        catch ( InvalidRepositoryException e )
+        MavenProject parent = project.getParent();
+        if ( parent != null )
         {
-            String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
-            throw new ProjectBuildingException( projectId, e.getMessage(), e );
+            parent.getModel().getBuild().setDirectory( parent.getFile().getAbsolutePath() );
+            setBuildOutputDirectoryOnParent( parent );
         }
     }
 
-    /**
-     * @todo can this take in a model instead of a project and still be successful?
-     * @todo In fact, does project REALLY need a MavenProject as a parent? Couldn't it have just a wrapper around a
-     * model that supported parents which were also the wrapper so that inheritence was assembled. We don't really need
-     * the resolved source roots, etc for the parent - that occurs for the parent when it is constructed independently
-     * and projects are not cached or reused
-     */
-    private MavenProject processProjectLogic( MavenProject project,
-                                              File pomFile,
-                                              ProjectBuilderConfiguration config,
-                                              List remoteRepositories,
-                                              boolean strict,
-                                              boolean isSuperPom )
-        throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
+    private static class DefaultModelDefaultsInjector
     {
-        Model model = project.getModel();
-
-        List activeProfiles = project.getActiveProfiles();
-
-        File projectDir = null;
-
-        if ( pomFile != null )
-        {
-            projectDir = pomFile.getAbsoluteFile().getParentFile();
-        }
-
-        Build dynamicBuild = model.getBuild();
-        model.setBuild( ModelUtils.cloneBuild( dynamicBuild ) );
-
-        model = modelInterpolator.interpolate( model, projectDir, config, getLogger().isDebugEnabled() );
-
-        mergeDeterministicBuildElements( model.getBuild(), dynamicBuild );
-        model.setBuild( dynamicBuild );
-
-        // We must inject any imported dependencyManagement information ahead of the defaults injection.
-        if ( !isSuperPom )
-        {
-            // TODO: [jdcasey] This line appears to be part of the problem for MNG-3391...
-            // the same line is in 2.0.x, so this is related to caching changes too...need to figure out how the two interact.
-            mergeManagedDependencies( model, config.getLocalRepository(), remoteRepositories );
-        }
-
-        // interpolation is before injection, because interpolation is off-limits in the injected variables
-        modelDefaultsInjector.injectDefaults( model );
-
-        MavenProject parentProject = project.getParent();
-
-        Model originalModel = project.getOriginalModel();
-
-        Artifact parentArtifact = project.getParentArtifact();
-
-        // We will return a different project object using the new model (hence the need to return a project, not just modify the parameter)
-        project = new MavenProject( model );
-
-        project.setOriginalModel( originalModel );
-
-        project.setActiveProfiles( activeProfiles );
-
-        // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
-        // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
-        Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
-            project.getVersion(), project.getPackaging() );
-        project.setArtifact( projectArtifact );
-
-//        project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( model.getPluginRepositories() ) );
-
-        DistributionManagement dm = model.getDistributionManagement();
-
-        if ( dm != null )
-        {
-            ArtifactRepository repo = mavenTools.buildDeploymentArtifactRepository( dm.getRepository() );
-            project.setReleaseArtifactRepository( repo );
-
-            if ( dm.getSnapshotRepository() != null )
-            {
-                repo = mavenTools.buildDeploymentArtifactRepository( dm.getSnapshotRepository() );
-                project.setSnapshotArtifactRepository( repo );
-            }
-        }
-
-        project.setParent( parentProject );
-
-        if ( parentProject != null )
-        {
-            project.setParentArtifact( parentArtifact );
-        }
-
-        validateModel( model, pomFile );
-
-        try
+        public void injectDefaults( Model model )
         {
-            LinkedHashSet repoSet = new LinkedHashSet();
-            if ( ( model.getRepositories() != null ) && !model.getRepositories().isEmpty() )
-            {
-                repoSet.addAll( model.getRepositories() );
-            }
-
-            if ( ( model.getPluginRepositories() != null ) && !model.getPluginRepositories().isEmpty() )
+            injectDependencyDefaults( model.getDependencies(), model.getDependencyManagement() );
+            if ( model.getBuild() != null )
             {
-                repoSet.addAll( model.getPluginRepositories() );
+                injectPluginDefaults( model.getBuild(), model.getBuild().getPluginManagement() );
             }
-
-            project.setRemoteArtifactRepositories(
-                                                  mavenTools.buildArtifactRepositories( new ArrayList( repoSet ) ) );
-        }
-        catch( Exception e )
-        {
-            e.printStackTrace();
         }
 
-        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
-        // TODO: these aren't taking active project artifacts into consideration in the reactor
-        project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins(), pomFile ) );
-
-        project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins(), pomFile ) );
-
-        project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions(), pomFile ) );
-
-        return project;
-    }
-
-    // TODO: Remove this!
-    @SuppressWarnings("unchecked")
-    private void mergeDeterministicBuildElements( Build interpolatedBuild,
-                                                  Build dynamicBuild )
-    {
-        List<Plugin> dPlugins = dynamicBuild.getPlugins();
-
-        if ( dPlugins != null )
+        private static void injectPluginDefaults( Build build, PluginManagement pluginManagement )
         {
-            List<Plugin> iPlugins = interpolatedBuild.getPlugins();
-
-            for ( int i = 0; i < dPlugins.size(); i++ )
+            if ( pluginManagement == null )
             {
-                Plugin dPlugin = dPlugins.get( i );
-                Plugin iPlugin = iPlugins.get( i );
-
-                dPlugin.setGroupId( iPlugin.getGroupId() );
-                dPlugin.setArtifactId( iPlugin.getArtifactId() );
-                dPlugin.setVersion( iPlugin.getVersion() );
-                
-                dPlugin.setDependencies( iPlugin.getDependencies() );
+                // nothing to inject.
+                return;
             }
-        }
 
-        PluginManagement dPluginMgmt = dynamicBuild.getPluginManagement();
+            List buildPlugins = build.getPlugins();
 
-        if ( dPluginMgmt != null )
-        {
-            PluginManagement iPluginMgmt = interpolatedBuild.getPluginManagement();
-            dPlugins = dPluginMgmt.getPlugins();
-            if ( dPlugins != null )
+            if ( buildPlugins != null && !buildPlugins.isEmpty() )
             {
-                List<Plugin> iPlugins = iPluginMgmt.getPlugins();
+                Map pmPlugins = pluginManagement.getPluginsAsMap();
 
-                for ( int i = 0; i < dPlugins.size(); i++ )
+                if ( pmPlugins != null && !pmPlugins.isEmpty() )
                 {
-                    Plugin dPlugin = dPlugins.get( i );
-                    Plugin iPlugin = iPlugins.get( i );
+                    for ( Iterator it = buildPlugins.iterator(); it.hasNext(); )
+                    {
+                        Plugin buildPlugin = (Plugin) it.next();
 
-                    dPlugin.setGroupId( iPlugin.getGroupId() );
-                    dPlugin.setArtifactId( iPlugin.getArtifactId() );
-                    dPlugin.setVersion( iPlugin.getVersion() );
-                    
-                    dPlugin.setDependencies( iPlugin.getDependencies() );
+                        Plugin pmPlugin = (Plugin) pmPlugins.get( buildPlugin.getKey() );
+
+                        if ( pmPlugin != null )
+                        {
+                            ModelUtils.mergePluginDefinitions( buildPlugin, pmPlugin, false );
+                        }
+                    }
                 }
             }
-        }
-
-        if ( dynamicBuild.getExtensions() != null )
-        {
-            dynamicBuild.setExtensions( interpolatedBuild.getExtensions() );
-        }
-    }
 
-    public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( project.isConcrete() )
-        {
-            return;
         }
 
-        Build build = project.getBuild();
-        if ( build != null )
+        private static void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement )
         {
-            initResourceMergeIds( build.getResources() );
-            initResourceMergeIds( build.getTestResources() );
-        }
-
-        Model model = ModelUtils.cloneModel( project.getModel() );
-
-        File basedir = project.getBasedir();
-
-        model = modelInterpolator.interpolate( model, basedir, config, getLogger().isDebugEnabled() );
-
-        List originalInterpolatedCompileSourceRoots = interpolateListOfStrings( project.getCompileSourceRoots(),
-                                                                           model,
-                                                                           project.getBasedir(),
-                                                                           config );
-
-        project.preserveCompileSourceRoots( originalInterpolatedCompileSourceRoots );
-
-        project.setCompileSourceRoots( originalInterpolatedCompileSourceRoots == null ? null
-                        : translateListOfPaths( originalInterpolatedCompileSourceRoots, basedir ) );
-
-        List originalInterpolatedTestCompileSourceRoots = interpolateListOfStrings( project.getTestCompileSourceRoots(),
-                                                                               model,
-                                                                               project.getBasedir(),
-                                                                               config );
-
-        project.preserveTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots );
-        project.setTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots == null ? null
-                        : translateListOfPaths( originalInterpolatedTestCompileSourceRoots, basedir ) );
-
-        List originalInterpolatedScriptSourceRoots = interpolateListOfStrings( project.getScriptSourceRoots(),
-                                                                          model,
-                                                                          project.getBasedir(),
-                                                                          config );
-
-        project.preserveScriptSourceRoots( originalInterpolatedScriptSourceRoots );
-        project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots == null ? null
-                        : translateListOfPaths( originalInterpolatedScriptSourceRoots, basedir ) );
-
-        Model model2 = ModelUtils.cloneModel( model );
-
-        pathTranslator.alignToBaseDirectory( model, basedir );
+            if ( dependencyManagement != null )
+            {
+                // a given project's dependencies should be smaller than the
+                // group-defined defaults set...
+                // in other words, the project's deps will probably be a subset of
+                // those specified in defaults.
+                Map depsMap = new TreeMap();
+                for ( Iterator it = dependencies.iterator(); it.hasNext(); )
+                {
+                    Dependency dep = (Dependency) it.next();
+                    depsMap.put( dep.getManagementKey(), dep );
+                }
 
-        project.preserveBuild( model2.getBuild() );
-        project.setBuild( model.getBuild() );
+                List managedDependencies = dependencyManagement.getDependencies();
 
-        calculateConcreteProjectReferences( project, config );
+                for ( Iterator it = managedDependencies.iterator(); it.hasNext(); )
+                {
+                    Dependency def = (Dependency) it.next();
+                    String key = def.getManagementKey();
 
-        MavenProject executionProject = project.getExecutionProject();
-        if ( executionProject != null && executionProject != project )
-        {
-            calculateConcreteState( executionProject, config );
+                    Dependency dep = (Dependency) depsMap.get( key );
+                    if ( dep != null )
+                    {
+                        mergeDependencyWithDefaults( dep, def );
+                    }
+                }
+            }
         }
 
-        project.setConcrete( true );
-    }
-
-    private void initResourceMergeIds( List<Resource> resources )
-    {
-        if ( resources != null )
+        private static void mergeDependencyWithDefaults( Dependency dep, Dependency def )
         {
-            for ( Resource resource : resources )
+            if ( dep.getScope() == null && def.getScope() != null )
             {
-                resource.initMergeId();
+                dep.setScope( def.getScope() );
+                dep.setSystemPath( def.getSystemPath() );
             }
-        }
-    }
-
-    private void calculateConcreteProjectReferences( MavenProject project,
-                                                     ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        Map projectRefs = project.getProjectReferences();
 
-        if ( projectRefs != null )
-        {
-            for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
+            if ( dep.getVersion() == null && def.getVersion() != null )
             {
-                MavenProject reference = (MavenProject) it.next();
-                calculateConcreteState( reference, config );
+                dep.setVersion( def.getVersion() );
             }
-        }
-    }
-
-    private List translateListOfPaths( List paths, File basedir )
-    {
-        if ( paths == null )
-        {
-            return null;
-        }
-        else if ( basedir == null )
-        {
-            return paths;
-        }
 
-        List result = new ArrayList( paths.size() );
-        for ( Iterator it = paths.iterator(); it.hasNext(); )
-        {
-            String path = (String) it.next();
+            if ( dep.getClassifier() == null && def.getClassifier() != null )
+            {
+                dep.setClassifier( def.getClassifier() );
+            }
 
-            String aligned = pathTranslator.alignToBaseDirectory( path, basedir );
+            if ( dep.getType() == null && def.getType() != null )
+            {
+                dep.setType( def.getType() );
+            }
 
-            result.add( aligned );
+            List exclusions = dep.getExclusions();
+            if ( exclusions == null || exclusions.isEmpty() )
+            {
+                dep.setExclusions( def.getExclusions() );
+            }
         }
-
-        return result;
     }
-
-    public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( !project.isConcrete() )
-        {
-            return;
-        }
-
-        restoreBuildRoots( project, config );
-        restoreModelBuildSection( project, config );
-
-        restoreDynamicProjectReferences( project, config );
-
-        MavenProject executionProject = project.getExecutionProject();
-        if ( executionProject != null && executionProject != project )
-        {
-            restoreDynamicState( executionProject, config );
-        }
-
-        project.setConcrete( false );
-    }
-
-    private void restoreDynamicProjectReferences( MavenProject project,
-                                                  ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        Map projectRefs = project.getProjectReferences();
-        if ( projectRefs != null )
-        {
-            for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
-            {
-                MavenProject projectRef = (MavenProject) it.next();
-                restoreDynamicState( projectRef, config );
-            }
-        }
-    }
-
-    private void restoreBuildRoots( MavenProject project,
-                                    ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        project.setCompileSourceRoots( restoreListOfStrings( project.getDynamicCompileSourceRoots(),
-                                                             project.getOriginalInterpolatedCompileSourceRoots(),
-                                                             project.getCompileSourceRoots(),
-                                                             project,
-                                                             config ) );
-
-        project.setTestCompileSourceRoots( restoreListOfStrings( project.getDynamicTestCompileSourceRoots(),
-                                                                 project.getOriginalInterpolatedTestCompileSourceRoots(),
-                                                                 project.getTestCompileSourceRoots(),
-                                                                 project,
-                                                                 config ) );
-
-        project.setScriptSourceRoots( restoreListOfStrings( project.getDynamicScriptSourceRoots(),
-                                                            project.getOriginalInterpolatedScriptSourceRoots(),
-                                                            project.getScriptSourceRoots(),
-                                                            project,
-                                                            config ) );
-
-        project.clearRestorableRoots();
-    }
-
-    private void restoreModelBuildSection( MavenProject project,
-                                           ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        Build changedBuild = project.getBuild();
-        Build dynamicBuild = project.getDynamicBuild();
-        Build originalInterpolatedBuild = project.getOriginalInterpolatedBuild();
-
-        dynamicBuild.setResources( restoreResources( dynamicBuild.getResources(),
-                                                         originalInterpolatedBuild.getResources(),
-                                                         changedBuild.getResources(),
-                                                         project,
-                                                         config ) );
-
-        dynamicBuild.setTestResources( restoreResources( dynamicBuild.getTestResources(),
-                                                         originalInterpolatedBuild.getTestResources(),
-                                                         changedBuild.getTestResources(),
-                                                         project,
-                                                         config ) );
-
-        dynamicBuild.setFilters( restoreListOfStrings( dynamicBuild.getFilters(),
-                                                           originalInterpolatedBuild.getFilters(),
-                                                           changedBuild.getFilters(),
-                                                           project,
-                                                           config ) );
-
-        dynamicBuild.setFinalName( restoreString( dynamicBuild.getFinalName(),
-                                                  originalInterpolatedBuild.getFinalName(),
-                                                  changedBuild.getFinalName(),
-                                                  project,
-                                                  config ) );
-
-        dynamicBuild.setDefaultGoal( restoreString( dynamicBuild.getDefaultGoal(),
-                                                  originalInterpolatedBuild.getDefaultGoal(),
-                                                  changedBuild.getDefaultGoal(),
-                                                  project,
-                                                  config ) );
-
-        dynamicBuild.setSourceDirectory( restoreString( dynamicBuild.getSourceDirectory(),
-                                                            originalInterpolatedBuild.getSourceDirectory(),
-                                                            changedBuild.getSourceDirectory(),
-                                                            project,
-                                                            config ) );
-
-        dynamicBuild.setTestSourceDirectory( restoreString( dynamicBuild.getTestSourceDirectory(),
-                                                                originalInterpolatedBuild.getTestSourceDirectory(),
-                                                                changedBuild.getTestSourceDirectory(),
-                                                                project,
-                                                                config ) );
-
-        dynamicBuild.setScriptSourceDirectory( restoreString( dynamicBuild.getScriptSourceDirectory(),
-                                                                  originalInterpolatedBuild.getScriptSourceDirectory(),
-                                                                  changedBuild.getScriptSourceDirectory(),
-                                                                  project,
-                                                                  config ) );
-
-        dynamicBuild.setOutputDirectory( restoreString( dynamicBuild.getOutputDirectory(),
-                                                            originalInterpolatedBuild.getOutputDirectory(),
-                                                            changedBuild.getOutputDirectory(),
-                                                            project,
-                                                            config ) );
-
-        dynamicBuild.setTestOutputDirectory( restoreString( dynamicBuild.getTestOutputDirectory(),
-                                                                originalInterpolatedBuild.getTestOutputDirectory(),
-                                                                changedBuild.getTestOutputDirectory(),
-                                                                project,
-                                                                config ) );
-
-        dynamicBuild.setDirectory( restoreString( dynamicBuild.getDirectory(),
-                                                      originalInterpolatedBuild.getDirectory(),
-                                                      changedBuild.getDirectory(),
-                                                      project,
-                                                      config ) );
-
-        project.setBuild( dynamicBuild );
-
-        project.clearRestorableBuild();
-    }
-
-    private List interpolateListOfStrings( List originalStrings,
-                                           Model model,
-                                           File projectDir,
-                                           ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( originalStrings == null )
-        {
-            return null;
-        }
-
-        List result = new ArrayList();
-
-        for ( Iterator it = originalStrings.iterator(); it.hasNext(); )
-        {
-            String original = (String) it.next();
-            String interpolated = modelInterpolator.interpolate( original, model, projectDir, config, getLogger().isDebugEnabled() );
-
-            result.add( interpolated );
-        }
-
-        return result;
-    }
-
-    private String restoreString( String originalString,
-                                      String originalInterpolatedString,
-                                      String changedString,
-                                      MavenProject project,
-                                      ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( originalString == null )
-        {
-            return changedString;
-        }
-        else if ( changedString == null )
-        {
-            return originalString;
-        }
-
-        Model model = project.getModel();
-
-        String relativeChangedString;
-        if ( project.getBasedir() != null )
-        {
-            relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
-        }
-        else
-        {
-            relativeChangedString = changedString;
-        }
-
-        String interpolatedOriginal = modelInterpolator.interpolate( originalString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
-        String interpolatedOriginal2 = modelInterpolator.interpolate( originalInterpolatedString,
-                                                                 model,
-                                                                 project.getBasedir(), config, getLogger().isDebugEnabled() );
-
-        String interpolatedChanged = modelInterpolator.interpolate( changedString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
-        String relativeInterpolatedChanged = modelInterpolator.interpolate( relativeChangedString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
-
-        if ( interpolatedOriginal.equals( interpolatedChanged )
-             || interpolatedOriginal2.equals( interpolatedChanged ) )
-        {
-            return originalString;
-        }
-        else if ( interpolatedOriginal.equals( relativeInterpolatedChanged )
-                        || interpolatedOriginal2.equals( relativeInterpolatedChanged ) )
-       {
-           return originalString;
-       }
-
-        return relativeChangedString;
-    }
-
-    private List restoreListOfStrings( List originalStrings,
-                                           List originalInterpolatedStrings,
-                                           List changedStrings,
-                                           MavenProject project,
-                                           ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( originalStrings == null )
-        {
-            return changedStrings;
-        }
-        else if ( changedStrings == null )
-        {
-            return originalStrings;
-        }
-
-        List result = new ArrayList();
-
-        Map orig = new HashMap();
-        for ( int idx = 0; idx < originalStrings.size(); idx++ )
-        {
-            String[] permutations = new String[2];
-
-            permutations[0] = (String) originalInterpolatedStrings.get( idx );
-            permutations[1] = (String) originalStrings.get( idx );
-
-            orig.put( permutations[0], permutations );
-        }
-
-        for ( Iterator it = changedStrings.iterator(); it.hasNext(); )
-        {
-            String changedString = (String) it.next();
-            String relativeChangedString;
-            if ( project.getBasedir() != null )
-            {
-                relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
-            }
-            else
-            {
-                relativeChangedString = changedString;
-            }
-
-            String interpolated = modelInterpolator.interpolate( changedString,
-                                                                 project.getModel(),
-                                                                 project.getBasedir(),
-                                                                 config,
-                                                                 getLogger().isDebugEnabled() );
-
-            String relativeInterpolated = modelInterpolator.interpolate( relativeChangedString,
-                                                                         project.getModel(),
-                                                                         project.getBasedir(),
-                                                                         config,
-                                                                         getLogger().isDebugEnabled() );
-
-            String[] original = (String[]) orig.get( interpolated );
-            if ( original == null )
-            {
-                original = (String[]) orig.get( relativeInterpolated );
-            }
-
-            if ( original == null )
-            {
-                result.add( relativeChangedString );
-            }
-            else
-            {
-                result.add( original[1] );
-            }
-        }
-
-        return result;
-    }
-
-    // TODO: Convert this to use the mergeId on each resource...
-    private List restoreResources( List<Resource> originalResources,
-                                       List<Resource> originalInterpolatedResources,
-                                       List<Resource> changedResources,
-                                       MavenProject project,
-                                       ProjectBuilderConfiguration config )
-        throws ModelInterpolationException
-    {
-        if ( originalResources == null || changedResources == null )
-        {
-            return originalResources;
-        }
-
-        List<Resource> result = new ArrayList<Resource>();
-
-        Map<String, Resource[]> originalResourcesByMergeId = new HashMap<String, Resource[]>();
-        for ( int idx = 0; idx < originalResources.size(); idx++ )
-        {
-            Resource[] permutations = new Resource[2];
-
-            permutations[0] = originalInterpolatedResources.get( idx );
-            permutations[1] = originalResources.get( idx );
-
-            originalResourcesByMergeId.put( permutations[0].getMergeId(), permutations );
-        }
-
-        for ( Resource resource : changedResources )
-        {
-            String mergeId = resource.getMergeId();
-            if ( mergeId == null || !originalResourcesByMergeId.containsKey( mergeId ) )
-            {
-                result.add( resource );
-            }
-            else
-            {
-                Resource originalInterpolatedResource = originalResourcesByMergeId.get( mergeId )[0];
-                Resource originalResource = originalResourcesByMergeId.get( mergeId )[1];
-
-                String dir = modelInterpolator.interpolate( resource.getDirectory(), project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() );
-                String oDir = originalInterpolatedResource.getDirectory();
-
-                if ( !dir.equals( oDir ) )
-                {
-                    originalResource.setDirectory( pathTranslator.unalignFromBaseDirectory( dir, project.getBasedir() ) );
-                }
-
-                if ( resource.getTargetPath() != null )
-                {
-                    String target = modelInterpolator.interpolate( resource.getTargetPath(), project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() );
-
-                    String oTarget = originalInterpolatedResource.getTargetPath();
-
-                    if ( !target.equals( oTarget ) )
-                    {
-                        originalResource.setTargetPath( pathTranslator.unalignFromBaseDirectory( target, project.getBasedir() ) );
-                    }
-                }
-
-                originalResource.setFiltering( resource.isFiltering() );
-
-                originalResource.setExcludes( collectRestoredListOfPatterns( resource.getExcludes(),
-                                                                             originalResource.getExcludes(),
-                                                                             originalInterpolatedResource.getExcludes() ) );
-
-                originalResource.setIncludes( collectRestoredListOfPatterns( resource.getIncludes(),
-                                                                             originalResource.getIncludes(),
-                                                                             originalInterpolatedResource.getIncludes() ) );
-
-                result.add( originalResource );
-            }
-        }
-
-        return result;
-    }
-
-    private List<String> collectRestoredListOfPatterns( List<String> patterns,
-                                                        List<String> originalPatterns,
-                                                        List<String> originalInterpolatedPatterns )
-    {
-        LinkedHashSet<String> collectedPatterns = new LinkedHashSet<String>();
-
-        collectedPatterns.addAll( originalPatterns );
-
-        for ( String pattern : patterns )
-        {
-            if ( !originalInterpolatedPatterns.contains( pattern ) )
-            {
-                collectedPatterns.add( pattern );
-            }
-        }
-
-        return (List<String>) ( collectedPatterns.isEmpty() ? Collections.emptyList()
-                        : new ArrayList<String>( collectedPatterns ) );
-    }
-
-    private void validateModel( Model model,
-                                File pomFile )
-        throws InvalidProjectModelException
-    {
-        // Must validate before artifact construction to make sure dependencies are good
-        ModelValidationResult validationResult = validator.validate( model );
-
-        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
-        if ( validationResult.getMessageCount() > 0 )
-        {
-            throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomFile,
-                validationResult );
-        }
-    }
-
-    /**
-     * @param isReactorProject
-     * @noinspection CollectionDeclaredAsConcreteClass
-     * @todo We need to find an effective way to unit test parts of this method!

[... 471 lines stripped ...]