You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2015/03/01 22:34:39 UTC

[1/3] maven git commit: MNG-5774 Provide an extension point for alternate CLI configuration source

Repository: maven
Updated Branches:
  refs/heads/master 50899962f -> be3fb2003


MNG-5774 Provide an extension point for alternate CLI configuration source


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

Branch: refs/heads/master
Commit: 7997634209cf2e666aa94ece24e089da179d8aa3
Parents: 5089996
Author: Jason van Zyl <ja...@tesla.io>
Authored: Sat Jan 24 17:37:00 2015 -0500
Committer: Jason van Zyl <ja...@tesla.io>
Committed: Sun Mar 1 10:22:26 2015 -0800

----------------------------------------------------------------------
 maven-core/pom.xml                              |   1 +
 .../java/org/apache/maven/DefaultMaven.java     |   2 +-
 .../maven/bridge/MavenRepositorySystem.java     |   2 +-
 .../execution/DefaultMavenExecutionRequest.java | 132 ++++++++
 .../maven/execution/MavenExecutionRequest.java  |  16 +
 .../MavenExecutionRequestPopulator.java         |   1 +
 .../java/org/apache/maven/cli/CliRequest.java   | 120 ++++++++
 .../java/org/apache/maven/cli/MavenCli.java     | 193 +++++-------
 .../configuration/ConfigurationProcessor.java   |  28 ++
 .../SettingsXmlConfigurationProcessor.java      | 308 +++++++++++++++++++
 .../java/org/apache/maven/cli/MavenCliTest.java |   1 -
 11 files changed, 679 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index f6158d4..75285a0 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -40,6 +40,7 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-model</artifactId>
     </dependency>
+    <!-- Remove the following two deps to see how to remove Settings from the core -->
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-settings</artifactId>

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 385ff74..20d3758 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -156,7 +156,7 @@ public class DefaultMaven
     //
     @SuppressWarnings( "checkstyle:methodlength" )
     private MavenExecutionResult doExecute( MavenExecutionRequest request )
-    {
+    {        
         request.setStartTime( new Date() );
 
         MavenExecutionResult result = new DefaultMavenExecutionResult();

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
index ad93785..c0f682e 100644
--- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
@@ -351,7 +351,7 @@ public class MavenRepositorySystem
         return modelRepositoryPolicy;
     }
 
-    public ArtifactRepository buildArtifactRepository( org.apache.maven.settings.Repository repo )
+    public static ArtifactRepository buildArtifactRepository( org.apache.maven.settings.Repository repo )
         throws InvalidRepositoryException
     {
         return buildArtifactRepository( fromSettingsRepository( repo ) );

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
index 9daba38..21a63a1 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingRequest;
@@ -40,6 +41,8 @@ import org.eclipse.aether.RepositoryCache;
 import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.transfer.TransferListener;
 
+import com.google.common.collect.Maps;
+
 /**
  * @author Jason van Zyl
  */
@@ -53,6 +56,8 @@ public class DefaultMavenExecutionRequest
 
     private ArtifactRepository localRepository;
 
+    private EventSpyDispatcher eventSpyDispatcher;
+    
     private File localRepositoryPath;
 
     private boolean offline = false;
@@ -156,6 +161,8 @@ public class DefaultMavenExecutionRequest
 
     private boolean useLegacyLocalRepositoryManager = false;
 
+    private Map<String, Object> data;
+    
     public DefaultMavenExecutionRequest()
     {
     }
@@ -203,6 +210,7 @@ public class DefaultMavenExecutionRequest
         return copy;
     }
 
+    @Override
     public String getBaseDirectory()
     {
         if ( basedir == null )
@@ -213,16 +221,19 @@ public class DefaultMavenExecutionRequest
         return basedir.getAbsolutePath();
     }
 
+    @Override
     public ArtifactRepository getLocalRepository()
     {
         return localRepository;
     }
 
+    @Override
     public File getLocalRepositoryPath()
     {
         return localRepositoryPath;
     }
 
+    @Override
     public List<String> getGoals()
     {
         if ( goals == null )
@@ -232,6 +243,7 @@ public class DefaultMavenExecutionRequest
         return goals;
     }
 
+    @Override
     public Properties getSystemProperties()
     {
         if ( systemProperties == null )
@@ -242,6 +254,7 @@ public class DefaultMavenExecutionRequest
         return systemProperties;
     }
 
+    @Override
     public Properties getUserProperties()
     {
         if ( userProperties == null )
@@ -252,16 +265,19 @@ public class DefaultMavenExecutionRequest
         return userProperties;
     }
 
+    @Override
     public File getPom()
     {
         return pom;
     }
 
+    @Override
     public String getReactorFailureBehavior()
     {
         return reactorFailureBehavior;
     }
 
+    @Override
     public List<String> getSelectedProjects()
     {
         if ( selectedProjects == null )
@@ -272,6 +288,7 @@ public class DefaultMavenExecutionRequest
         return selectedProjects;
     }
 
+    @Override
     public List<String> getExcludedProjects()
     {
         if ( excludedProjects == null )
@@ -282,31 +299,37 @@ public class DefaultMavenExecutionRequest
         return excludedProjects;
     }
 
+    @Override
     public String getResumeFrom()
     {
         return resumeFrom;
     }
 
+    @Override
     public String getMakeBehavior()
     {
         return makeBehavior;
     }
 
+    @Override
     public Date getStartTime()
     {
         return startTime;
     }
 
+    @Override
     public boolean isShowErrors()
     {
         return showErrors;
     }
 
+    @Override
     public boolean isInteractiveMode()
     {
         return interactiveMode;
     }
 
+    @Override
     public MavenExecutionRequest setActiveProfiles( List<String> activeProfiles )
     {
         if ( activeProfiles != null )
@@ -321,6 +344,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setInactiveProfiles( List<String> inactiveProfiles )
     {
         if ( inactiveProfiles != null )
@@ -335,6 +359,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
     {
         if ( remoteRepositories != null )
@@ -349,6 +374,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
     {
         if ( pluginArtifactRepositories != null )
@@ -368,6 +394,7 @@ public class DefaultMavenExecutionRequest
         this.projectBuildingRequest = projectBuildingConfiguration;
     }
 
+    @Override
     public List<String> getActiveProfiles()
     {
         if ( activeProfiles == null )
@@ -377,6 +404,7 @@ public class DefaultMavenExecutionRequest
         return activeProfiles;
     }
 
+    @Override
     public List<String> getInactiveProfiles()
     {
         if ( inactiveProfiles == null )
@@ -386,36 +414,43 @@ public class DefaultMavenExecutionRequest
         return inactiveProfiles;
     }
 
+    @Override
     public TransferListener getTransferListener()
     {
         return transferListener;
     }
 
+    @Override
     public int getLoggingLevel()
     {
         return loggingLevel;
     }
 
+    @Override
     public boolean isOffline()
     {
         return offline;
     }
 
+    @Override
     public boolean isUpdateSnapshots()
     {
         return updateSnapshots;
     }
 
+    @Override
     public boolean isNoSnapshotUpdates()
     {
         return noSnapshotUpdates;
     }
 
+    @Override
     public String getGlobalChecksumPolicy()
     {
         return globalChecksumPolicy;
     }
 
+    @Override
     public boolean isRecursive()
     {
         return recursive;
@@ -425,6 +460,7 @@ public class DefaultMavenExecutionRequest
     //
     // ----------------------------------------------------------------------
 
+    @Override
     public MavenExecutionRequest setBaseDirectory( File basedir )
     {
         this.basedir = basedir;
@@ -432,6 +468,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setStartTime( Date startTime )
     {
         this.startTime = startTime;
@@ -439,6 +476,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setShowErrors( boolean showErrors )
     {
         this.showErrors = showErrors;
@@ -446,6 +484,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setGoals( List<String> goals )
     {
         if ( goals != null )
@@ -460,6 +499,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository )
     {
         this.localRepository = localRepository;
@@ -472,6 +512,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setLocalRepositoryPath( File localRepository )
     {
         localRepositoryPath = localRepository;
@@ -479,6 +520,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setLocalRepositoryPath( String localRepository )
     {
         localRepositoryPath = ( localRepository != null ) ? new File( localRepository ) : null;
@@ -486,6 +528,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setSystemProperties( Properties properties )
     {
         if ( properties != null )
@@ -501,6 +544,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setUserProperties( Properties userProperties )
     {
         if ( userProperties != null )
@@ -516,6 +560,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setReactorFailureBehavior( String failureBehavior )
     {
         reactorFailureBehavior = failureBehavior;
@@ -523,6 +568,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setSelectedProjects( List<String> selectedProjects )
     {
         if ( selectedProjects != null )
@@ -537,6 +583,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setExcludedProjects( List<String> excludedProjects )
     {
         if ( excludedProjects != null )
@@ -551,6 +598,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setResumeFrom( String project )
     {
         this.resumeFrom = project;
@@ -558,6 +606,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setMakeBehavior( String makeBehavior )
     {
         this.makeBehavior = makeBehavior;
@@ -565,6 +614,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addActiveProfile( String profile )
     {
         if ( !getActiveProfiles().contains( profile ) )
@@ -575,6 +625,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addInactiveProfile( String profile )
     {
         if ( !getInactiveProfiles().contains( profile ) )
@@ -585,6 +636,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addActiveProfiles( List<String> profiles )
     {
         for ( String profile : profiles )
@@ -595,6 +647,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addInactiveProfiles( List<String> profiles )
     {
         for ( String profile : profiles )
@@ -618,6 +671,7 @@ public class DefaultMavenExecutionRequest
     }
 
     /** @deprecated use {@link #setPom(File)} */
+    @Deprecated
     public MavenExecutionRequest setPomFile( String pomFilename )
     {
         if ( pomFilename != null )
@@ -628,6 +682,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setPom( File pom )
     {
         this.pom = pom;
@@ -635,6 +690,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setInteractiveMode( boolean interactive )
     {
         interactiveMode = interactive;
@@ -642,6 +698,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setTransferListener( TransferListener transferListener )
     {
         this.transferListener = transferListener;
@@ -649,6 +706,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setLoggingLevel( int loggingLevel )
     {
         this.loggingLevel = loggingLevel;
@@ -656,6 +714,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setOffline( boolean offline )
     {
         this.offline = offline;
@@ -663,6 +722,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots )
     {
         this.updateSnapshots = updateSnapshots;
@@ -670,6 +730,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates )
     {
         this.noSnapshotUpdates = noSnapshotUpdates;
@@ -677,6 +738,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
     {
         this.globalChecksumPolicy = globalChecksumPolicy;
@@ -688,6 +750,7 @@ public class DefaultMavenExecutionRequest
     // Settings equivalents
     // ----------------------------------------------------------------------------
 
+    @Override
     public List<Proxy> getProxies()
     {
         if ( proxies == null )
@@ -697,6 +760,7 @@ public class DefaultMavenExecutionRequest
         return proxies;
     }
 
+    @Override
     public MavenExecutionRequest setProxies( List<Proxy> proxies )
     {
         if ( proxies != null )
@@ -711,6 +775,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addProxy( Proxy proxy )
     {
         if ( proxy == null )
@@ -731,6 +796,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<Server> getServers()
     {
         if ( servers == null )
@@ -740,6 +806,7 @@ public class DefaultMavenExecutionRequest
         return servers;
     }
 
+    @Override
     public MavenExecutionRequest setServers( List<Server> servers )
     {
         if ( servers != null )
@@ -754,6 +821,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addServer( Server server )
     {
         if ( server == null )
@@ -774,6 +842,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<Mirror> getMirrors()
     {
         if ( mirrors == null )
@@ -783,6 +852,7 @@ public class DefaultMavenExecutionRequest
         return mirrors;
     }
 
+    @Override
     public MavenExecutionRequest setMirrors( List<Mirror> mirrors )
     {
         if ( mirrors != null )
@@ -797,6 +867,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addMirror( Mirror mirror )
     {
         if ( mirror == null )
@@ -817,6 +888,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<Profile> getProfiles()
     {
         if ( profiles == null )
@@ -826,6 +898,7 @@ public class DefaultMavenExecutionRequest
         return profiles;
     }
 
+    @Override
     public MavenExecutionRequest setProfiles( List<Profile> profiles )
     {
         if ( profiles != null )
@@ -840,6 +913,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<String> getPluginGroups()
     {
         if ( pluginGroups == null )
@@ -850,6 +924,7 @@ public class DefaultMavenExecutionRequest
         return pluginGroups;
     }
 
+    @Override
     public MavenExecutionRequest setPluginGroups( List<String> pluginGroups )
     {
         if ( pluginGroups != null )
@@ -864,6 +939,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addPluginGroup( String pluginGroup )
     {
         if ( !getPluginGroups().contains( pluginGroup ) )
@@ -874,6 +950,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addPluginGroups( List<String> pluginGroups )
     {
         for ( String pluginGroup : pluginGroups )
@@ -884,6 +961,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setRecursive( boolean recursive )
     {
         this.recursive = recursive;
@@ -894,11 +972,13 @@ public class DefaultMavenExecutionRequest
     // calculated from request attributes.
     private ProjectBuildingRequest projectBuildingRequest;
 
+    @Override
     public boolean isProjectPresent()
     {
         return isProjectPresent;
     }
 
+    @Override
     public MavenExecutionRequest setProjectPresent( boolean projectPresent )
     {
         isProjectPresent = projectPresent;
@@ -908,11 +988,13 @@ public class DefaultMavenExecutionRequest
 
     // Settings files
 
+    @Override
     public File getUserSettingsFile()
     {
         return userSettingsFile;
     }
 
+    @Override
     public MavenExecutionRequest setUserSettingsFile( File userSettingsFile )
     {
         this.userSettingsFile = userSettingsFile;
@@ -920,11 +1002,13 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public File getGlobalSettingsFile()
     {
         return globalSettingsFile;
     }
 
+    @Override
     public MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile )
     {
         this.globalSettingsFile = globalSettingsFile;
@@ -932,11 +1016,13 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public File getUserToolchainsFile()
     {
         return userToolchainsFile;
     }
 
+    @Override
     public MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile )
     {
         this.userToolchainsFile = userToolchainsFile;
@@ -957,6 +1043,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository )
     {
         for ( ArtifactRepository repo : getRemoteRepositories() )
@@ -972,6 +1059,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<ArtifactRepository> getRemoteRepositories()
     {
         if ( remoteRepositories == null )
@@ -981,6 +1069,7 @@ public class DefaultMavenExecutionRequest
         return remoteRepositories;
     }
 
+    @Override
     public MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository )
     {
         for ( ArtifactRepository repo : getPluginArtifactRepositories() )
@@ -996,6 +1085,7 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public List<ArtifactRepository> getPluginArtifactRepositories()
     {
         if ( pluginArtifactRepositories == null )
@@ -1006,6 +1096,7 @@ public class DefaultMavenExecutionRequest
     }
 
     // TODO: this does not belong here.
+    @Override
     public ProjectBuildingRequest getProjectBuildingRequest()
     {
         if ( projectBuildingRequest == null )
@@ -1026,6 +1117,7 @@ public class DefaultMavenExecutionRequest
         return projectBuildingRequest;
     }
 
+    @Override
     public MavenExecutionRequest addProfile( Profile profile )
     {
         if ( profile == null )
@@ -1046,11 +1138,13 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public RepositoryCache getRepositoryCache()
     {
         return repositoryCache;
     }
 
+    @Override
     public MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache )
     {
         this.repositoryCache = repositoryCache;
@@ -1058,11 +1152,13 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public ExecutionListener getExecutionListener()
     {
         return executionListener;
     }
 
+    @Override
     public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener )
     {
         this.executionListener = executionListener;
@@ -1070,66 +1166,78 @@ public class DefaultMavenExecutionRequest
         return this;
     }
 
+    @Override
     public void setDegreeOfConcurrency( final int degreeOfConcurrency )
     {
         this.degreeOfConcurrency = degreeOfConcurrency;
     }
 
+    @Override
     public int getDegreeOfConcurrency()
     {
         return degreeOfConcurrency;
     }
 
+    @Override
     public WorkspaceReader getWorkspaceReader()
     {
         return workspaceReader;
     }
 
+    @Override
     public MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader )
     {
         this.workspaceReader = workspaceReader;
         return this;
     }
 
+    @Override
     public boolean isCacheTransferError()
     {
         return cacheTransferError;
     }
 
+    @Override
     public MavenExecutionRequest setCacheTransferError( boolean cacheTransferError )
     {
         this.cacheTransferError = cacheTransferError;
         return this;
     }
 
+    @Override
     public boolean isCacheNotFound()
     {
         return cacheNotFound;
     }
 
+    @Override
     public MavenExecutionRequest setCacheNotFound( boolean cacheNotFound )
     {
         this.cacheNotFound = cacheNotFound;
         return this;
     }
 
+    @Override
     public boolean isUseLegacyLocalRepository()
     {
         return this.useLegacyLocalRepositoryManager;
     }
 
+    @Override
     public MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepositoryManager )
     {
         this.useLegacyLocalRepositoryManager = useLegacyLocalRepositoryManager;
         return this;
     }
 
+    @Override
     public MavenExecutionRequest setBuilderId( String builderId )
     {
         this.builderId = builderId;
         return this;
     }
 
+    @Override
     public String getBuilderId()
     {
         return builderId;
@@ -1163,4 +1271,28 @@ public class DefaultMavenExecutionRequest
     {
         return multiModuleProjectDirectory;
     }
+        
+    @Override
+    public MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher )
+    {
+        this.eventSpyDispatcher = eventSpyDispatcher;
+        return this;
+    }
+
+    @Override
+    public EventSpyDispatcher getEventSpyDispatcher()
+    {
+        return eventSpyDispatcher;
+    }
+    
+    @Override
+    public Map<String, Object> getData()
+    {
+        if ( data == null )
+        {
+            data = Maps.newHashMap();
+        }
+
+        return data;
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
index bb4a49a..b88f728 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
@@ -27,6 +27,7 @@ import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.ProjectBuildingRequest;
 //
@@ -424,4 +425,19 @@ public interface MavenExecutionRequest
      * @since 3.2.6
      */
     File getMultiModuleProjectDirectory();
+
+    /**
+     * @since 3.2.6
+     */    
+    MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher );
+    
+    /**
+     * @since 3.2.6
+     */
+    EventSpyDispatcher getEventSpyDispatcher();
+
+    /**
+     * @since 3.2.6
+     */
+    Map<String, Object> getData();
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
index 8eb805c..677e8c2 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
@@ -40,6 +40,7 @@ public interface MavenExecutionRequestPopulator
      * @return The populated execution request, never {@code null}.
      * @throws MavenExecutionRequestPopulationException If the execution request could not be populated.
      */
+    @Deprecated
     MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
         throws MavenExecutionRequestPopulationException;
 

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
new file mode 100644
index 0000000..4656dd3
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
@@ -0,0 +1,120 @@
+package org.apache.maven.cli;
+
+/*
+ * 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.Properties;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.codehaus.plexus.classworlds.ClassWorld;
+
+public class CliRequest
+{
+    String[] args;
+
+    CommandLine commandLine;
+
+    ClassWorld classWorld;
+
+    String workingDirectory;
+
+    File multiModuleProjectDirectory;
+
+    boolean debug;
+
+    boolean quiet;
+
+    boolean showErrors = true;
+
+    Properties userProperties = new Properties();
+
+    Properties systemProperties = new Properties();
+
+    MavenExecutionRequest request;
+
+    CliRequest( String[] args, ClassWorld classWorld )
+    {
+        this.args = args;
+        this.classWorld = classWorld;
+        this.request = new DefaultMavenExecutionRequest();
+    }
+
+    public String[] getArgs()
+    {
+        return args;
+    }
+
+    public CommandLine getCommandLine()
+    {
+        return commandLine;
+    }
+
+    public ClassWorld getClassWorld()
+    {
+        return classWorld;
+    }
+
+    public String getWorkingDirectory()
+    {
+        return workingDirectory;
+    }
+
+    public File getMultiModuleProjectDirectory()
+    {
+        return multiModuleProjectDirectory;
+    }
+
+    public boolean isDebug()
+    {
+        return debug;
+    }
+
+    public boolean isQuiet()
+    {
+        return quiet;
+    }
+
+    public boolean isShowErrors()
+    {
+        return showErrors;
+    }
+
+    public Properties getUserProperties()
+    {
+        return userProperties;
+    }
+
+    public Properties getSystemProperties()
+    {
+        return systemProperties;
+    }
+
+    public MavenExecutionRequest getRequest()
+    {
+        return request;
+    }
+
+    public void setUserProperties( Properties properties ) 
+    {
+        this.userProperties.putAll( properties );      
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 4e7e072..ced883c 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -35,6 +35,7 @@ import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -48,6 +49,8 @@ import org.apache.maven.Maven;
 import org.apache.maven.building.FileSource;
 import org.apache.maven.building.Problem;
 import org.apache.maven.building.Source;
+import org.apache.maven.cli.configuration.ConfigurationProcessor;
+import org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor;
 import org.apache.maven.cli.event.DefaultEventSpyContext;
 import org.apache.maven.cli.event.ExecutionEventLogger;
 import org.apache.maven.cli.internal.BootstrapCoreExtensionManager;
@@ -77,11 +80,6 @@ import org.apache.maven.model.building.ModelProcessor;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.properties.internal.EnvironmentUtils;
 import org.apache.maven.properties.internal.SystemProperties;
-import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
-import org.apache.maven.settings.building.SettingsBuilder;
-import org.apache.maven.settings.building.SettingsBuildingRequest;
-import org.apache.maven.settings.building.SettingsBuildingResult;
-import org.apache.maven.settings.building.SettingsProblem;
 import org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest;
 import org.apache.maven.toolchain.building.ToolchainsBuilder;
 import org.apache.maven.toolchain.building.ToolchainsBuildingResult;
@@ -132,11 +130,6 @@ public class MavenCli
     @SuppressWarnings( "checkstyle:constantname" )
     public static final File userMavenConfigurationHome = new File( userHome, ".m2" );
 
-    public static final File DEFAULT_USER_SETTINGS_FILE = new File( userMavenConfigurationHome, "settings.xml" );
-
-    public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
-        new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/settings.xml" );
-
     public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" );
 
     public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = 
@@ -162,12 +155,12 @@ public class MavenCli
 
     private MavenExecutionRequestPopulator executionRequestPopulator;
 
-    private SettingsBuilder settingsBuilder;
-
     private ToolchainsBuilder toolchainsBuilder;
 
     private DefaultSecDispatcher dispatcher;
 
+    private Map<String, ConfigurationProcessor> configurationProcessors;
+    
     public MavenCli()
     {
         this( null );
@@ -274,7 +267,7 @@ public class MavenCli
             properties( cliRequest );
             localContainer = container( cliRequest );
             commands( cliRequest );
-            settings( cliRequest );
+            configure( cliRequest );
             toolchains( cliRequest );
             populateRequest( cliRequest );
             encryption( cliRequest );
@@ -581,8 +574,8 @@ public class MavenCli
 
         modelProcessor = createModelProcessor( container );
 
-        settingsBuilder = container.lookup( SettingsBuilder.class );
-
+        configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
+        
         toolchainsBuilder = container.lookup( ToolchainsBuilder.class );
 
         dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
@@ -639,20 +632,24 @@ public class MavenCli
                 Thread.currentThread().setContextClassLoader( container.getContainerRealm() );
 
                 executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class );
-                settingsBuilder = container.lookup( SettingsBuilder.class );
-
+                
+                configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
+                
+                configure( cliRequest );
+                
                 MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request );
-                settings( cliRequest, request );
+
                 request = populateRequest( cliRequest, request );
+                
                 request = executionRequestPopulator.populateDefaults( request );
 
                 BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class );
+                
                 return resolver.loadCoreExtensions( request, providedArtifacts, extensions );
             }
             finally
             {
                 executionRequestPopulator = null;
-                settingsBuilder = null;
                 container.dispose();
             }
         }
@@ -979,93 +976,69 @@ public class MavenCli
     }
 
     @SuppressWarnings( "checkstyle:methodlength" )
-    private void settings( CliRequest cliRequest )
+    private void configure( CliRequest cliRequest )
         throws Exception
     {
-        settings( cliRequest, cliRequest.request );
-    }
-
-    private void settings( CliRequest cliRequest, MavenExecutionRequest request )
-        throws Exception
-    {
-        File userSettingsFile;
-
-        if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) )
-        {
-            userSettingsFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) );
-            userSettingsFile = resolveFile( userSettingsFile, cliRequest.workingDirectory );
-
-            if ( !userSettingsFile.isFile() )
-            {
-                throw new FileNotFoundException( "The specified user settings file does not exist: "
-                    + userSettingsFile );
-            }
-        }
-        else
+        //
+        // This is not ideal but there are events specifically for configuration from the CLI which I don't
+        // believe are really valid but there are ITs which assert the right events are published so this
+        // needs to be supported so the EventSpyDispatcher needs to be put in the CliRequest so that
+        // it can be accessed by configuration processors.
+        //
+        cliRequest.request.setEventSpyDispatcher( eventSpyDispatcher );
+        
+        //
+        // We expect at most 2 implementations to be available. The SettingsXmlConfigurationProcessor implementation
+        // is always available in the core and likely always will be, but we may have another ConfigurationProcessor
+        // present supplied by the user. The rule is that we only allow the execution of one ConfigurationProcessor.
+        // If there is more than one then we execute the one supplied by the user, otherwise we execute the
+        // the default SettingsXmlConfigurationProcessor.
+        // 
+        int userSuppliedConfigurationProcessorCount = configurationProcessors.size() - 1;
+        
+        if ( userSuppliedConfigurationProcessorCount == 0 )
         {
-            userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
-        }
-
-        File globalSettingsFile;
-
-        if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) )
+            //
+            // Our settings.xml source is historically how we have configured Maven from the CLI so we are going to 
+            // have to honour its existence forever. So let's run it.
+            //
+            configurationProcessors.get( SettingsXmlConfigurationProcessor.HINT ).process( cliRequest );            
+        }        
+        else if ( userSuppliedConfigurationProcessorCount == 1 )
         {
-            globalSettingsFile =
-                new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) );
-            globalSettingsFile = resolveFile( globalSettingsFile, cliRequest.workingDirectory );
-
-            if ( !globalSettingsFile.isFile() )
+            //
+            // Run the user supplied ConfigurationProcessor
+            //
+            for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() )
             {
-                throw new FileNotFoundException( "The specified global settings file does not exist: "
-                    + globalSettingsFile );
-            }
-        }
-        else
-        {
-            globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
-        }
-
-        request.setGlobalSettingsFile( globalSettingsFile );
-        request.setUserSettingsFile( userSettingsFile );
-
-        SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
-        settingsRequest.setGlobalSettingsFile( globalSettingsFile );
-        settingsRequest.setUserSettingsFile( userSettingsFile );
-        settingsRequest.setSystemProperties( cliRequest.systemProperties );
-        settingsRequest.setUserProperties( cliRequest.userProperties );
-
-        if ( eventSpyDispatcher != null )
-        {
-            eventSpyDispatcher.onEvent( settingsRequest );
-        }
-
-        slf4jLogger.debug( "Reading global settings from "
-            + getLocation( settingsRequest.getGlobalSettingsSource(),
-                                   settingsRequest.getGlobalSettingsFile() ) );
-        slf4jLogger.debug( "Reading user settings from "
-            + getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
-
-        SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
-
-        if ( eventSpyDispatcher != null )
-        {
-            eventSpyDispatcher.onEvent( settingsResult );
+                String hint = entry.getKey();
+                if ( !hint.equals( SettingsXmlConfigurationProcessor.HINT ) )
+                {
+                    ConfigurationProcessor configurationProcessor = entry.getValue();
+                    configurationProcessor.process( cliRequest );
+                }
+            }            
         }
-
-        executionRequestPopulator.populateFromSettings( request, settingsResult.getEffectiveSettings() );
-
-        if ( !settingsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() )
+        else if ( userSuppliedConfigurationProcessorCount > 1 )
         {
-            slf4jLogger.warn( "" );
-            slf4jLogger.warn( "Some problems were encountered while building the effective settings" );
-
-            for ( SettingsProblem problem : settingsResult.getProblems() )
+            //
+            // There are too many ConfigurationProcessors so we don't know which one to run so report the error.
+            //
+            StringBuffer sb = new StringBuffer( 
+                String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n", 
+                               userSuppliedConfigurationProcessorCount ) );
+            for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() )
             {
-                slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+                String hint = entry.getKey();
+                if ( !hint.equals( SettingsXmlConfigurationProcessor.HINT ) )
+                {
+                    ConfigurationProcessor configurationProcessor = entry.getValue();
+                    sb.append( String.format( "%s\n", configurationProcessor.getClass().getName() ) );
+                }
             }
-
-            slf4jLogger.warn( "" );
-        }
+            sb.append( String.format( "\n" ) );
+            throw new Exception( sb.toString() );
+        }                
     }
     
     @SuppressWarnings( "checkstyle:methodlength" )
@@ -1346,8 +1319,7 @@ public class MavenCli
             .setUpdateSnapshots( updateSnapshots ) // default: false
             .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
             .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
-            .setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory )
-            ;
+            .setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory );
 
         if ( alternatePomFile != null )
         {
@@ -1589,28 +1561,6 @@ public class MavenCli
         System.setProperty( name, value );
     }
 
-    static class CliRequest
-    {
-        String[] args;
-        CommandLine commandLine;
-        ClassWorld classWorld;
-        String workingDirectory;
-        File multiModuleProjectDirectory;
-        boolean debug;
-        boolean quiet;
-        boolean showErrors = true;
-        Properties userProperties = new Properties();
-        Properties systemProperties = new Properties();
-        MavenExecutionRequest request;
-
-        CliRequest( String[] args, ClassWorld classWorld )
-        {
-            this.args = args;
-            this.classWorld = classWorld;
-            this.request = new DefaultMavenExecutionRequest();
-        }
-    }
-
     static class ExitException
         extends Exception
     {
@@ -1621,7 +1571,6 @@ public class MavenCli
         {
             this.exitCode = exitCode;
         }
-
     }
 
     //

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java
new file mode 100644
index 0000000..75fb9b9
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java
@@ -0,0 +1,28 @@
+package org.apache.maven.cli.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.cli.CliRequest;
+
+public interface ConfigurationProcessor
+{
+    void process( CliRequest request )
+        throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
new file mode 100644
index 0000000..890a658
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
@@ -0,0 +1,308 @@
+package org.apache.maven.cli.configuration;
+
+/*
+ * 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.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.bridge.MavenRepositorySystem;
+import org.apache.maven.building.Source;
+import org.apache.maven.cli.CLIManager;
+import org.apache.maven.cli.CliRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequestPopulationException;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Repository;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.SettingsUtils;
+import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
+import org.apache.maven.settings.building.SettingsBuilder;
+import org.apache.maven.settings.building.SettingsBuildingRequest;
+import org.apache.maven.settings.building.SettingsBuildingResult;
+import org.apache.maven.settings.building.SettingsProblem;
+import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
+import org.apache.maven.settings.crypto.SettingsDecrypter;
+import org.apache.maven.settings.crypto.SettingsDecryptionResult;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.slf4j.Logger;
+
+@Component( role = ConfigurationProcessor.class, hint = SettingsXmlConfigurationProcessor.HINT )
+public class SettingsXmlConfigurationProcessor
+    implements ConfigurationProcessor
+{
+    public static final String HINT = "settings";
+
+    public static final String USER_HOME = System.getProperty( "user.home" );
+
+    public static final File USER_MAVEN_CONFIGURATION_HOME = new File( USER_HOME, ".m2" );
+
+    public static final File DEFAULT_USER_SETTINGS_FILE = new File( USER_MAVEN_CONFIGURATION_HOME, "settings.xml" );
+
+    public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System.getProperty( "maven.home", System
+        .getProperty( "user.dir", "" ) ), "conf/settings.xml" );
+
+    @Requirement
+    private Logger logger;
+
+    @Requirement
+    private SettingsBuilder settingsBuilder;
+
+    @Requirement
+    private SettingsDecrypter settingsDecrypter;
+
+    @Override
+    public void process( CliRequest cliRequest )
+        throws Exception
+    {
+        CommandLine commandLine = cliRequest.getCommandLine();
+        String workingDirectory = cliRequest.getWorkingDirectory();
+        MavenExecutionRequest request = cliRequest.getRequest();
+
+        File userSettingsFile;
+
+        if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) )
+        {
+            userSettingsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) );
+            userSettingsFile = resolveFile( userSettingsFile, workingDirectory );
+
+            if ( !userSettingsFile.isFile() )
+            {
+                throw new FileNotFoundException( "The specified user settings file does not exist: "
+                    + userSettingsFile );
+            }
+        }
+        else
+        {
+            userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
+        }
+
+        File globalSettingsFile;
+
+        if ( commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) )
+        {
+            globalSettingsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) );
+            globalSettingsFile = resolveFile( globalSettingsFile, workingDirectory );
+
+            if ( !globalSettingsFile.isFile() )
+            {
+                throw new FileNotFoundException( "The specified global settings file does not exist: "
+                    + globalSettingsFile );
+            }
+        }
+        else
+        {
+            globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
+        }
+
+        request.setGlobalSettingsFile( globalSettingsFile );
+        request.setUserSettingsFile( userSettingsFile );
+
+        SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
+        settingsRequest.setGlobalSettingsFile( globalSettingsFile );
+        settingsRequest.setUserSettingsFile( userSettingsFile );
+        settingsRequest.setSystemProperties( cliRequest.getSystemProperties() );
+        settingsRequest.setUserProperties( cliRequest.getUserProperties() );
+
+        if ( request.getEventSpyDispatcher() != null )
+        {
+            request.getEventSpyDispatcher().onEvent( settingsRequest );
+        }
+
+        logger.debug( "Reading global settings from "
+            + getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
+        logger.debug( "Reading user settings from "
+            + getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
+
+        SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
+
+        if ( request.getEventSpyDispatcher() != null )
+        {
+            request.getEventSpyDispatcher().onEvent( settingsResult );
+        }
+
+        populateFromSettings( request, settingsResult.getEffectiveSettings() );
+
+        if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
+        {
+            logger.warn( "" );
+            logger.warn( "Some problems were encountered while building the effective settings" );
+
+            for ( SettingsProblem problem : settingsResult.getProblems() )
+            {
+                logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+            }
+            logger.warn( "" );
+        }
+
+        DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
+        decrypt.setProxies( request.getProxies() );
+        decrypt.setServers( request.getServers() );
+        SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
+
+        if ( logger.isDebugEnabled() )
+        {
+            for ( SettingsProblem problem : decrypted.getProblems() )
+            {
+                logger.debug( problem.getMessage(), problem.getException() );
+            }
+        }
+
+        request.setProxies( decrypt.getProxies() );
+        request.setServers( decrypt.getServers() );
+    }
+
+    public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
+        throws MavenExecutionRequestPopulationException
+    {
+        if ( settings == null )
+        {
+            return request;
+        }
+
+        request.setOffline( settings.isOffline() );
+
+        request.setInteractiveMode( settings.isInteractiveMode() );
+
+        request.setPluginGroups( settings.getPluginGroups() );
+
+        request.setLocalRepositoryPath( settings.getLocalRepository() );
+
+        for ( Server server : settings.getServers() )
+        {
+            server = server.clone();
+
+            request.addServer( server );
+        }
+
+        //  <proxies>
+        //    <proxy>
+        //      <active>true</active>
+        //      <protocol>http</protocol>
+        //      <host>proxy.somewhere.com</host>
+        //      <port>8080</port>
+        //      <username>proxyuser</username>
+        //      <password>somepassword</password>
+        //      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
+        //    </proxy>
+        //  </proxies>
+
+        for ( Proxy proxy : settings.getProxies() )
+        {
+            if ( !proxy.isActive() )
+            {
+                continue;
+            }
+
+            proxy = proxy.clone();
+
+            request.addProxy( proxy );
+        }
+
+        // <mirrors>
+        //   <mirror>
+        //     <id>nexus</id>
+        //     <mirrorOf>*</mirrorOf>
+        //     <url>http://repository.sonatype.org/content/groups/public</url>
+        //   </mirror>
+        // </mirrors>
+
+        for ( Mirror mirror : settings.getMirrors() )
+        {
+            mirror = mirror.clone();
+
+            request.addMirror( mirror );
+        }
+
+        request.setActiveProfiles( settings.getActiveProfiles() );
+
+        for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
+        {
+            request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) );
+
+            if ( settings.getActiveProfiles().contains( rawProfile.getId() ) )
+            {
+                List<Repository> remoteRepositories = rawProfile.getRepositories();
+                for ( Repository remoteRepository : remoteRepositories )
+                {
+                    try
+                    {
+                        request.addRemoteRepository( 
+                            MavenRepositorySystem.buildArtifactRepository( remoteRepository ) );
+                    }
+                    catch ( InvalidRepositoryException e )
+                    {
+                        // do nothing for now
+                    }
+                }
+                
+                List<Repository> pluginRepositories = rawProfile.getPluginRepositories();
+                for ( Repository pluginRepository : pluginRepositories )
+                {
+                    try
+                    {
+                        request.addPluginArtifactRepository( 
+                            MavenRepositorySystem.buildArtifactRepository( pluginRepository ) );
+                    }
+                    catch ( InvalidRepositoryException e )
+                    {
+                        // do nothing for now
+                    }
+                }                
+            }
+        }
+        return request;
+    }
+
+    private Object getLocation( Source source, File defaultLocation )
+    {
+        if ( source != null )
+        {
+            return source.getLocation();
+        }
+        return defaultLocation;
+    }
+
+    static File resolveFile( File file, String workingDirectory )
+    {
+        if ( file == null )
+        {
+            return null;
+        }
+        else if ( file.isAbsolute() )
+        {
+            return file;
+        }
+        else if ( file.getPath().startsWith( File.separator ) )
+        {
+            // drive-relative Windows path
+            return file.getAbsoluteFile();
+        }
+        else
+        {
+            return new File( workingDirectory, file.getPath() ).getAbsoluteFile();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/79976342/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index 0c85dfb..c8d75b1 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -24,7 +24,6 @@ import java.io.File;
 import junit.framework.TestCase;
 
 import org.apache.commons.cli.ParseException;
-import org.apache.maven.cli.MavenCli.CliRequest;
 
 public class MavenCliTest
     extends TestCase


[3/3] maven git commit: MNG-5775 Make the project graph building code pluggable to allow for new/different implementations.

Posted by jv...@apache.org.
MNG-5775 Make the project graph building code pluggable to allow for new/different implementations.


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

Branch: refs/heads/master
Commit: be3fb200326208ca4b8c41ebf16d5ae6b8049792
Parents: 7997634
Author: Jason van Zyl <ja...@tesla.io>
Authored: Wed Sep 3 11:48:28 2014 -0700
Committer: Jason van Zyl <ja...@tesla.io>
Committed: Sun Mar 1 12:39:30 2015 -0800

----------------------------------------------------------------------
 .../DefaultArtifactDescriptorReader.java        |  14 +-
 .../internal/MavenWorkspaceReader.java          |  32 ++
 .../java/org/apache/maven/DefaultMaven.java     | 500 +++----------------
 .../maven/DefaultProjectDependencyGraph.java    | 134 -----
 .../maven/FilteredProjectDependencyGraph.java   | 111 ----
 .../org/apache/maven/ProjectCycleException.java |   5 +
 .../java/org/apache/maven/ReactorReader.java    |  13 +-
 .../apache/maven/execution/MavenSession.java    |   9 +-
 .../apache/maven/graph/DefaultGraphBuilder.java | 487 ++++++++++++++++++
 .../graph/DefaultProjectDependencyGraph.java    | 134 +++++
 .../graph/FilteredProjectDependencyGraph.java   | 111 ++++
 .../org/apache/maven/graph/GraphBuilder.java    |  31 ++
 .../project/DefaultModelBuildingListener.java   |   2 +-
 .../org/apache/maven/project/MavenProject.java  |   2 +-
 .../maven/project/ProjectModelResolver.java     |   3 +-
 .../DefaultProjectDependencyGraphTest.java      | 172 -------
 .../DefaultProjectDependencyGraphTest.java      | 172 +++++++
 .../maven/lifecycle/LifecycleExecutorTest.java  |   5 +
 maven-model-builder/pom.xml                     |   5 +-
 .../model/building/DefaultModelBuilder.java     | 291 +++++++----
 .../building/DefaultModelBuildingRequest.java   |  32 ++
 .../building/FilterModelBuildingRequest.java    |  30 +-
 .../maven/model/building/ModelBuilder.java      |  13 +
 .../model/building/ModelBuildingRequest.java    |  22 +-
 .../org/apache/maven/model/building/Result.java | 255 ++++++++++
 .../resolution/UnresolvableModelException.java  |  16 +
 .../resolution/WorkspaceModelResolver.java      |  33 ++
 maven-model/src/main/mdo/maven.mdo              |   8 +-
 28 files changed, 1676 insertions(+), 966 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
index 0fea15a..a768de5 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
@@ -52,6 +52,7 @@ import org.eclipse.aether.impl.RemoteRepositoryManager;
 import org.eclipse.aether.impl.RepositoryEventDispatcher;
 import org.eclipse.aether.impl.VersionRangeResolver;
 import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.repository.WorkspaceRepository;
 import org.eclipse.aether.resolution.ArtifactDescriptorException;
 import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
@@ -215,7 +216,6 @@ public class DefaultArtifactDescriptorReader
         ArtifactDescriptorResult result = new ArtifactDescriptorResult( request );
 
         Model model = loadPom( session, request, result );
-
         if ( model != null )
         {
             Map<String, Object> config = session.getConfigProperties();
@@ -303,6 +303,18 @@ public class DefaultArtifactDescriptorReader
             }
 
             Model model;
+
+            // hack: don't rebuild model if it was already loaded during reactor resolution
+            final WorkspaceReader workspace = session.getWorkspaceReader();
+            if ( workspace instanceof MavenWorkspaceReader )
+            {
+                model = ( (MavenWorkspaceReader) workspace ).findModel( pomArtifact );
+                if ( model != null )
+                {
+                    return model;
+                }
+            }
+
             try
             {
                 ModelBuildingRequest modelRequest = new DefaultModelBuildingRequest();

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
new file mode 100644
index 0000000..270cf58
--- /dev/null
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
@@ -0,0 +1,32 @@
+package org.apache.maven.repository.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 org.apache.maven.model.Model;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+
+public interface MavenWorkspaceReader
+    extends WorkspaceReader
+{
+
+    Model findModel( Artifact artifact );
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 20d3758..3009301 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -9,7 +9,7 @@ package org.apache.maven;
  * "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
+ *   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
@@ -25,7 +25,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -39,20 +38,15 @@ import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.graph.GraphBuilder;
 import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory;
 import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
 import org.apache.maven.lifecycle.internal.LifecycleStarter;
-import org.apache.maven.model.Plugin;
 import org.apache.maven.model.building.ModelProblem;
-import org.apache.maven.model.building.ModelProblemUtils;
-import org.apache.maven.model.building.ModelSource;
-import org.apache.maven.model.building.UrlModelSource;
+import org.apache.maven.model.building.Result;
 import org.apache.maven.plugin.LegacySupport;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.project.ProjectBuildingResult;
 import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
 import org.apache.maven.session.scope.internal.SessionScope;
 import org.codehaus.plexus.PlexusContainer;
@@ -60,13 +54,13 @@ import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.dag.CycleDetectedException;
 import org.eclipse.aether.DefaultRepositorySystemSession;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
 
+import com.google.common.collect.Iterables;
+
 /**
  * @author Jason van Zyl
  */
@@ -99,6 +93,9 @@ public class DefaultMaven
     @Requirement
     private DefaultRepositorySystemSessionFactory repositorySessionFactory;
 
+    @Requirement( hint = GraphBuilder.HINT )
+    private GraphBuilder graphBuilder;
+
     @Override
     public MavenExecutionResult execute( MavenExecutionRequest request )
     {
@@ -114,9 +111,18 @@ public class DefaultMaven
         }
         catch ( RuntimeException e )
         {
-            result =
-                addExceptionToResult( new DefaultMavenExecutionResult(), new InternalErrorException( "Internal error: "
-                    + e, e ) );
+            //TODO Hack to make the cycle detection the same for the new graph builder
+            if ( e.getCause() instanceof ProjectCycleException )
+            {
+                result = addExceptionToResult( new DefaultMavenExecutionResult(), e.getCause() );
+            }
+            else
+            {
+                result = addExceptionToResult( new DefaultMavenExecutionResult(), new InternalErrorException(
+                                                                                                              "Internal error: "
+                                                                                                                  + e,
+                                                                                                              e ) );
+            }
         }
         finally
         {
@@ -140,17 +146,17 @@ public class DefaultMaven
     // 6) Get reactor projects looking for general POM errors
     //
     // 7) Create ProjectDependencyGraph using trimming which takes into account --projects and reactor mode.
-    //    This ensures that the projects passed into the ReactorReader are only those specified.
+    // This ensures that the projects passed into the ReactorReader are only those specified.
     //
     // 8) Create ReactorReader with the getProjectMap( projects ). NOTE that getProjectMap(projects) is the code that
-    //    checks for duplicate projects definitions in the build. Ideally this type of duplicate checking should be
-    //    part of getting the reactor projects in 6). The duplicate checking is conflated with getProjectMap(projects).
+    // checks for duplicate projects definitions in the build. Ideally this type of duplicate checking should be
+    // part of getting the reactor projects in 6). The duplicate checking is conflated with getProjectMap(projects).
     //
     // 9) Execute AbstractLifecycleParticipant.afterProjectsRead(session)
     //
     // 10) Create ProjectDependencyGraph without trimming (as trimming was done in 7). A new topological sort is
-    //     required after the execution of 9) as the AbstractLifecycleParticipants are free to mutate the MavenProject
-    //     instances, which may change dependencies which can, in turn, affect the build order.
+    // required after the execution of 9) as the AbstractLifecycleParticipants are free to mutate the MavenProject
+    // instances, which may change dependencies which can, in turn, affect the build order.
     //
     // 11) Execute LifecycleStarter.start()
     //
@@ -171,7 +177,8 @@ public class DefaultMaven
         }
 
         //
-        // We enter the session scope right after the MavenSession creation and before any of the AbstractLifecycleParticipant lookups
+        // We enter the session scope right after the MavenSession creation and before any of the
+        // AbstractLifecycleParticipant lookups
         // so that @SessionScoped components can be @Injected into AbstractLifecycleParticipants.
         //
         sessionScope.enter();
@@ -198,7 +205,8 @@ public class DefaultMaven
     {
         try
         {
-            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList() ) )
+            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections
+                .<MavenProject>emptyList() ) )
             {
                 listener.afterSessionStart( session );
             }
@@ -210,36 +218,15 @@ public class DefaultMaven
 
         eventCatapult.fire( ExecutionEvent.Type.ProjectDiscoveryStarted, session, null );
 
-        List<MavenProject> projects;
-        try
-        {
-            projects = getProjectsForMavenReactor( session );
-            //
-            // Capture the full set of projects before any potential constraining is performed by --projects
-            //
-            session.setAllProjects( projects );
-        }
-        catch ( ProjectBuildingException e )
-        {
-            return addExceptionToResult( result, e );
-        }
-
-        validateProjects( projects );
-
-        //
-        // This creates the graph and trims the projects down based on the user request using something like:
-        //
-        // -pl project0,project2 eclipse:eclipse
-        //
-        ProjectDependencyGraph projectDependencyGraph = createProjectDependencyGraph( projects, request, result, true );
-
-        if ( result.hasExceptions() )
+        Result<? extends ProjectDependencyGraph> graphResult = buildGraph( session, result );
+        
+        if ( graphResult.hasErrors() )
         {
-            return result;
+            return addExceptionToResult( result,
+                                         Iterables.toArray( graphResult.getProblems(), ModelProblem.class )[0]
+                                             .getException() );
         }
 
-        session.setProjects( projectDependencyGraph.getSortedProjects() );
-
         try
         {
             session.setProjectMap( getProjectMap( session.getProjects() ) );
@@ -274,7 +261,7 @@ public class DefaultMaven
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
-            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( projects ) )
+            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( session.getProjects() ) )
             {
                 Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() );
 
@@ -298,7 +285,15 @@ public class DefaultMaven
         // Note that participants may affect the topological order of the projects but it is
         // not expected that a participant will add or remove projects from the session.
         //
-        projectDependencyGraph = createProjectDependencyGraph( session.getProjects(), request, result, false );
+        
+        graphResult = buildGraph( session, result );
+        
+        if ( graphResult.hasErrors() )
+        {
+            return addExceptionToResult( result,
+                                         Iterables.toArray( graphResult.getProblems(), ModelProblem.class )[0]
+                                             .getException() );
+        }
 
         try
         {
@@ -307,10 +302,6 @@ public class DefaultMaven
                 return result;
             }
 
-            session.setProjects( projectDependencyGraph.getSortedProjects() );
-
-            session.setProjectDependencyGraph( projectDependencyGraph );
-
             result.setTopologicallySortedProjects( session.getProjects() );
 
             result.setProject( session.getTopLevelProject() );
@@ -328,7 +319,7 @@ public class DefaultMaven
         {
             try
             {
-                afterSessionEnd( projects, session );
+                afterSessionEnd( session.getProjects(), session );
             }
             catch ( MavenExecutionException e )
             {
@@ -357,7 +348,7 @@ public class DefaultMaven
             Thread.currentThread().setContextClassLoader( originalClassLoader );
         }
     }
-
+    
     public RepositorySystemSession newRepositorySession( MavenExecutionRequest request )
     {
         return repositorySessionFactory.newRepositorySession( request );
@@ -380,8 +371,7 @@ public class DefaultMaven
 
     private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects )
     {
-        Collection<AbstractMavenLifecycleParticipant> lifecycleListeners =
-            new LinkedHashSet<AbstractMavenLifecycleParticipant>();
+        Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = new LinkedHashSet<AbstractMavenLifecycleParticipant>();
 
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         try
@@ -436,72 +426,22 @@ public class DefaultMaven
         return result;
     }
 
-    private List<MavenProject> getProjectsForMavenReactor( MavenSession session )
-        throws ProjectBuildingException
-    {
-        MavenExecutionRequest request = session.getRequest();
-
-        request.getProjectBuildingRequest().setRepositorySession( session.getRepositorySession() );
-
-        List<MavenProject> projects = new ArrayList<MavenProject>();
-
-        // We have no POM file.
-        //
-        if ( request.getPom() == null )
-        {
-            ModelSource modelSource = new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) );
-            MavenProject project =
-                projectBuilder.build( modelSource, request.getProjectBuildingRequest() ).getProject();
-            project.setExecutionRoot( true );
-            projects.add( project );
-            request.setProjectPresent( false );
-            return projects;
-        }
-
-        List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
-        collectProjects( projects, files, request );
-        return projects;
-    }
-
-    private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
-        throws ProjectBuildingException
+    private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds )
     {
-        ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
-
-        List<ProjectBuildingResult> results =
-            projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );
-
-        boolean problems = false;
+        Collection<String> notActivatedProfileIds = new LinkedHashSet<String>( activeProfileIds );
 
-        for ( ProjectBuildingResult result : results )
+        for ( MavenProject project : projects )
         {
-            projects.add( result.getProject() );
-
-            if ( !result.getProblems().isEmpty() && logger.isWarnEnabled() )
+            for ( List<String> profileIds : project.getInjectedProfileIds().values() )
             {
-                logger.warn( "" );
-                logger.warn( "Some problems were encountered while building the effective model for "
-                    + result.getProject().getId() );
-
-                for ( ModelProblem problem : result.getProblems() )
-                {
-                    String loc = ModelProblemUtils.formatLocation( problem, result.getProjectId() );
-                    logger.warn( problem.getMessage() + ( StringUtils.isNotEmpty( loc ) ? " @ " + loc : "" ) );
-                }
-
-                problems = true;
+                notActivatedProfileIds.removeAll( profileIds );
             }
         }
 
-        if ( problems )
+        for ( String notActivatedProfileId : notActivatedProfileIds )
         {
-            logger.warn( "" );
-            logger.warn( "It is highly recommended to fix these problems"
-                + " because they threaten the stability of your build." );
-            logger.warn( "" );
-            logger.warn( "For this reason, future Maven versions might no"
-                + " longer support building such malformed projects." );
-            logger.warn( "" );
+            logger.warn( "The requested profile \"" + notActivatedProfileId
+                + "\" could not be activated because it does not exist." );
         }
     }
 
@@ -547,330 +487,36 @@ public class DefaultMaven
         return index;
     }
 
-    private void validateProjects( List<MavenProject> projects )
+    private Result<? extends ProjectDependencyGraph> buildGraph( MavenSession session, MavenExecutionResult result ) 
     {
-        Map<String, MavenProject> projectsMap = new HashMap<String, MavenProject>();
-
-        for ( MavenProject p : projects )
+        Result<? extends ProjectDependencyGraph> graphResult = graphBuilder.build( session );
+        for ( ModelProblem problem : graphResult.getProblems() )
         {
-            String projectKey = ArtifactUtils.key( p.getGroupId(), p.getArtifactId(), p.getVersion() );
-
-            projectsMap.put( projectKey, p );
-        }
-
-        for ( MavenProject project : projects )
-        {
-            // MNG-1911 / MNG-5572: Building plugins with extensions cannot be part of reactor
-            for ( Plugin plugin : project.getBuildPlugins() )
+            if ( problem.getSeverity() == ModelProblem.Severity.WARNING )
             {
-                if ( plugin.isExtensions() )
-                {
-                    String pluginKey =
-                        ArtifactUtils.key( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() );
-
-                    if ( projectsMap.containsKey( pluginKey ) )
-                    {
-                        logger.warn( project.getName() + " uses " + plugin.getKey()
-                            + " as extensions, which is not possible within the same reactor build. "
-                            + "This plugin was pulled from the local repository!" );
-                    }
-                }
+                logger.warn( problem.toString() );
             }
-        }
-    }
-
-    private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds )
-    {
-        Collection<String> notActivatedProfileIds = new LinkedHashSet<String>( activeProfileIds );
-
-        for ( MavenProject project : projects )
-        {
-            for ( List<String> profileIds : project.getInjectedProfileIds().values() )
+            else
             {
-                notActivatedProfileIds.removeAll( profileIds );
+                logger.error( problem.toString() );
             }
         }
 
-        for ( String notActivatedProfileId : notActivatedProfileIds )
+        if ( !graphResult.hasErrors() )
         {
-            logger.warn( "The requested profile \"" + notActivatedProfileId
-                + "\" could not be activated because it does not exist." );
+            ProjectDependencyGraph projectDependencyGraph = graphResult.get();
+            session.setProjects( projectDependencyGraph.getSortedProjects() );
+            session.setAllProjects( projectDependencyGraph.getSortedProjects() );
+            session.setProjectDependencyGraph( projectDependencyGraph );                
         }
+        
+        return graphResult;        
     }
-
-    @Deprecated // 5 January 2014
+    
+    @Deprecated
+    // 5 January 2014
     protected Logger getLogger()
     {
         return logger;
     }
-
-    private ProjectDependencyGraph createProjectDependencyGraph( Collection<MavenProject> projects,
-                                                                 MavenExecutionRequest request,
-                                                                 MavenExecutionResult result, boolean trimming )
-    {
-        ProjectDependencyGraph projectDependencyGraph = null;
-
-        try
-        {
-            projectDependencyGraph = new DefaultProjectDependencyGraph( projects );
-
-            if ( trimming )
-            {
-                List<MavenProject> activeProjects = projectDependencyGraph.getSortedProjects();
-
-                activeProjects = trimSelectedProjects( activeProjects, projectDependencyGraph, request );
-                activeProjects = trimExcludedProjects( activeProjects,  request );
-                activeProjects = trimResumedProjects( activeProjects, request );
-
-                if ( activeProjects.size() != projectDependencyGraph.getSortedProjects().size() )
-                {
-                    projectDependencyGraph =
-                        new FilteredProjectDependencyGraph( projectDependencyGraph, activeProjects );
-                }
-            }
-        }
-        catch ( CycleDetectedException e )
-        {
-            String message = "The projects in the reactor contain a cyclic reference: " + e.getMessage();
-
-            ProjectCycleException error = new ProjectCycleException( message, e );
-
-            addExceptionToResult( result, error );
-        }
-        catch ( org.apache.maven.project.DuplicateProjectException e )
-        {
-            addExceptionToResult( result, e );
-        }
-        catch ( MavenExecutionException e )
-        {
-            addExceptionToResult( result, e );
-        }
-
-        return projectDependencyGraph;
-    }
-
-    private List<MavenProject> trimSelectedProjects( List<MavenProject> projects, ProjectDependencyGraph graph,
-                                                     MavenExecutionRequest request )
-        throws MavenExecutionException
-    {
-        List<MavenProject> result = projects;
-
-        if ( !request.getSelectedProjects().isEmpty() )
-        {
-            File reactorDirectory = null;
-            if ( request.getBaseDirectory() != null )
-            {
-                reactorDirectory = new File( request.getBaseDirectory() );
-            }
-
-            Collection<MavenProject> selectedProjects = new LinkedHashSet<MavenProject>( projects.size() );
-
-            for ( String selector : request.getSelectedProjects() )
-            {
-                MavenProject selectedProject = null;
-
-                for ( MavenProject project : projects )
-                {
-                    if ( isMatchingProject( project, selector, reactorDirectory ) )
-                    {
-                        selectedProject = project;
-                        break;
-                    }
-                }
-
-                if ( selectedProject != null )
-                {
-                    selectedProjects.add( selectedProject );
-                }
-                else
-                {
-                    throw new MavenExecutionException( "Could not find the selected project in the reactor: "
-                        + selector, request.getPom() );
-                }
-            }
-
-            boolean makeUpstream = false;
-            boolean makeDownstream = false;
-
-            if ( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM.equals( request.getMakeBehavior() ) )
-            {
-                makeUpstream = true;
-            }
-            else if ( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM.equals( request.getMakeBehavior() ) )
-            {
-                makeDownstream = true;
-            }
-            else if ( MavenExecutionRequest.REACTOR_MAKE_BOTH.equals( request.getMakeBehavior() ) )
-            {
-                makeUpstream = true;
-                makeDownstream = true;
-            }
-            else if ( StringUtils.isNotEmpty( request.getMakeBehavior() ) )
-            {
-                throw new MavenExecutionException( "Invalid reactor make behavior: " + request.getMakeBehavior(),
-                                                   request.getPom() );
-            }
-
-            if ( makeUpstream || makeDownstream )
-            {
-                for ( MavenProject selectedProject : new ArrayList<MavenProject>( selectedProjects ) )
-                {
-                    if ( makeUpstream )
-                    {
-                        selectedProjects.addAll( graph.getUpstreamProjects( selectedProject, true ) );
-                    }
-                    if ( makeDownstream )
-                    {
-                        selectedProjects.addAll( graph.getDownstreamProjects( selectedProject, true ) );
-                    }
-                }
-            }
-
-            result = new ArrayList<MavenProject>( selectedProjects.size() );
-
-            for ( MavenProject project : projects )
-            {
-                if ( selectedProjects.contains( project ) )
-                {
-                    result.add( project );
-                }
-            }
-        }
-
-        return result;
-    }
-
-    private List<MavenProject> trimExcludedProjects( List<MavenProject> projects, MavenExecutionRequest request )
-        throws MavenExecutionException
-    {
-        List<MavenProject> result = projects;
-
-        if ( !request.getExcludedProjects().isEmpty() )
-        {
-            File reactorDirectory = null;
-
-            if ( request.getBaseDirectory() != null )
-            {
-                reactorDirectory = new File( request.getBaseDirectory() );
-            }
-
-            Collection<MavenProject> excludedProjects = new LinkedHashSet<MavenProject>( projects.size() );
-
-            for ( String selector : request.getExcludedProjects() )
-            {
-                MavenProject excludedProject = null;
-
-                for ( MavenProject project : projects )
-                {
-                    if ( isMatchingProject( project, selector, reactorDirectory ) )
-                    {
-                        excludedProject = project;
-                        break;
-                    }
-                }
-
-                if ( excludedProject != null )
-                {
-                    excludedProjects.add( excludedProject );
-                }
-                else
-                {
-                    throw new MavenExecutionException( "Could not find the selected project in the reactor: "
-                        + selector, request.getPom() );
-                }
-            }
-
-            result = new ArrayList<MavenProject>( projects.size() );
-            for ( MavenProject project : projects )
-            {
-                if ( !excludedProjects.contains( project ) )
-                {
-                    result.add( project );
-                }
-            }
-        }
-
-        return result;
-    }
-
-    private List<MavenProject> trimResumedProjects( List<MavenProject> projects, MavenExecutionRequest request )
-        throws MavenExecutionException
-    {
-        List<MavenProject> result = projects;
-
-        if ( StringUtils.isNotEmpty( request.getResumeFrom() ) )
-        {
-            File reactorDirectory = null;
-            if ( request.getBaseDirectory() != null )
-            {
-                reactorDirectory = new File( request.getBaseDirectory() );
-            }
-
-            String selector = request.getResumeFrom();
-
-            result = new ArrayList<MavenProject>( projects.size() );
-
-            boolean resumed = false;
-
-            for ( MavenProject project : projects )
-            {
-                if ( !resumed && isMatchingProject( project, selector, reactorDirectory ) )
-                {
-                    resumed = true;
-                }
-
-                if ( resumed )
-                {
-                    result.add( project );
-                }
-            }
-
-            if ( !resumed )
-            {
-                throw new MavenExecutionException( "Could not find project to resume reactor build from: " + selector
-                    + " vs " + projects, request.getPom() );
-            }
-        }
-
-        return result;
-    }
-
-    private boolean isMatchingProject( MavenProject project, String selector, File reactorDirectory )
-    {
-        // [groupId]:artifactId
-        if ( selector.indexOf( ':' ) >= 0 )
-        {
-            String id = ':' + project.getArtifactId();
-
-            if ( id.equals( selector ) )
-            {
-                return true;
-            }
-
-            id = project.getGroupId() + id;
-
-            if ( id.equals( selector ) )
-            {
-                return true;
-            }
-        }
-
-        // relative path, e.g. "sub", "../sub" or "."
-        else if ( reactorDirectory != null )
-        {
-            File selectedProject = new File( new File( reactorDirectory, selector ).toURI().normalize() );
-
-            if ( selectedProject.isFile() )
-            {
-                return selectedProject.equals( project.getFile() );
-            }
-            else if ( selectedProject.isDirectory() )
-            {
-                return selectedProject.equals( project.getBasedir() );
-            }
-        }
-
-        return false;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/DefaultProjectDependencyGraph.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependencyGraph.java
deleted file mode 100644
index 4074e58..0000000
--- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependencyGraph.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.apache.maven;
-
-/*
- * 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.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.execution.ProjectDependencyGraph;
-import org.apache.maven.project.DuplicateProjectException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectSorter;
-import org.codehaus.plexus.util.dag.CycleDetectedException;
-
-/**
- * Describes the inter-dependencies between projects in the reactor.
- *
- * @author Benjamin Bentmann
- */
-class DefaultProjectDependencyGraph
-    implements ProjectDependencyGraph
-{
-
-    private ProjectSorter sorter;
-
-    /**
-     * Creates a new project dependency graph based on the specified projects.
-     *
-     * @param projects The projects to create the dependency graph with
-     * @throws DuplicateProjectException
-     * @throws CycleDetectedException
-     */
-    public DefaultProjectDependencyGraph( Collection<MavenProject> projects )
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        this.sorter = new ProjectSorter( projects );
-    }
-
-    public List<MavenProject> getSortedProjects()
-    {
-        return new ArrayList<MavenProject>( sorter.getSortedProjects() );
-    }
-
-    public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
-    {
-        if ( project == null )
-        {
-            throw new IllegalArgumentException( "project missing" );
-        }
-
-        Set<String> projectIds = new HashSet<String>();
-
-        getDownstreamProjects( ProjectSorter.getId( project ), projectIds, transitive );
-
-        return getSortedProjects( projectIds );
-    }
-
-    private void getDownstreamProjects( String projectId, Set<String> projectIds, boolean transitive )
-    {
-        for ( String id : sorter.getDependents( projectId ) )
-        {
-            if ( projectIds.add( id ) && transitive )
-            {
-                getDownstreamProjects( id, projectIds, transitive );
-            }
-        }
-    }
-
-    public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
-    {
-        if ( project == null )
-        {
-            throw new IllegalArgumentException( "project missing" );
-        }
-
-        Set<String> projectIds = new HashSet<String>();
-
-        getUpstreamProjects( ProjectSorter.getId( project ), projectIds, transitive );
-
-        return getSortedProjects( projectIds );
-    }
-
-    private void getUpstreamProjects( String projectId, Collection<String> projectIds, boolean transitive )
-    {
-        for ( String id : sorter.getDependencies( projectId ) )
-        {
-            if ( projectIds.add( id ) && transitive )
-            {
-                getUpstreamProjects( id, projectIds, transitive );
-            }
-        }
-    }
-
-    private List<MavenProject> getSortedProjects( Set<String> projectIds )
-    {
-        List<MavenProject> result = new ArrayList<MavenProject>( projectIds.size() );
-
-        for ( MavenProject mavenProject : sorter.getSortedProjects() )
-        {
-            if ( projectIds.contains( ProjectSorter.getId( mavenProject ) ) )
-            {
-                result.add( mavenProject );
-            }
-        }
-
-        return result;
-    }
-
-    @Override
-    public String toString()
-    {
-        return sorter.getSortedProjects().toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/FilteredProjectDependencyGraph.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/FilteredProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/FilteredProjectDependencyGraph.java
deleted file mode 100644
index e5db6bd..0000000
--- a/maven-core/src/main/java/org/apache/maven/FilteredProjectDependencyGraph.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.maven;
-
-/*
- * 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.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.execution.ProjectDependencyGraph;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Provides a sub view of another dependency graph.
- *
- * @author Benjamin Bentmann
- */
-class FilteredProjectDependencyGraph
-    implements ProjectDependencyGraph
-{
-
-    private ProjectDependencyGraph projectDependencyGraph;
-
-    private Map<MavenProject, ?> whiteList;
-
-    private List<MavenProject> sortedProjects;
-
-    /**
-     * Creates a new project dependency graph from the specified graph.
-     *
-     * @param projectDependencyGraph The project dependency graph to create a sub view from, must not be {@code null}.
-     * @param whiteList The projects on which the dependency view should focus, must not be {@code null}.
-     */
-    public FilteredProjectDependencyGraph( ProjectDependencyGraph projectDependencyGraph,
-                                           Collection<? extends MavenProject> whiteList )
-    {
-        if ( projectDependencyGraph == null )
-        {
-            throw new IllegalArgumentException( "project dependency graph missing" );
-        }
-
-        this.projectDependencyGraph = projectDependencyGraph;
-
-        this.whiteList = new IdentityHashMap<MavenProject, Object>();
-
-        for ( MavenProject project : whiteList )
-        {
-            this.whiteList.put( project, null );
-        }
-    }
-
-    public List<MavenProject> getSortedProjects()
-    {
-        if ( sortedProjects == null )
-        {
-            sortedProjects = applyFilter( projectDependencyGraph.getSortedProjects() );
-        }
-
-        return new ArrayList<MavenProject>( sortedProjects );
-    }
-
-    public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
-    {
-        return applyFilter( projectDependencyGraph.getDownstreamProjects( project, transitive ) );
-    }
-
-    public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
-    {
-        return applyFilter( projectDependencyGraph.getUpstreamProjects( project, transitive ) );
-    }
-
-    private List<MavenProject> applyFilter( Collection<? extends MavenProject> projects )
-    {
-        List<MavenProject> filtered = new ArrayList<MavenProject>( projects.size() );
-
-        for ( MavenProject project : projects )
-        {
-            if ( whiteList.containsKey( project ) )
-            {
-                filtered.add( project );
-            }
-        }
-
-        return filtered;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getSortedProjects().toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java b/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java
index cba4462..ecd8eca 100644
--- a/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java
+++ b/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java
@@ -27,6 +27,11 @@ import org.codehaus.plexus.util.dag.CycleDetectedException;
 public class ProjectCycleException
     extends BuildFailureException
 {
+    public ProjectCycleException( String message )
+    {
+        super( message );
+    }
+    
     public ProjectCycleException( String message, CycleDetectedException cause )
     {
         super( message, cause );

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/ReactorReader.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 3aca28d..252bdd0 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -34,9 +34,10 @@ import javax.inject.Named;
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Model;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
 import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.repository.WorkspaceRepository;
 import org.eclipse.aether.util.artifact.ArtifactIdUtils;
 
@@ -49,7 +50,7 @@ import org.eclipse.aether.util.artifact.ArtifactIdUtils;
 @Named( ReactorReader.HINT )
 @SessionScoped
 class ReactorReader
-    implements WorkspaceReader
+    implements MavenWorkspaceReader
 {
     public static final String HINT = "reactor";
 
@@ -136,6 +137,14 @@ class ReactorReader
         return Collections.unmodifiableList( versions );
     }
 
+    @Override
+    public Model findModel( Artifact artifact )
+    {
+        String projectKey = ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
+        MavenProject project = projectsByGAV.get( projectKey );
+        return project == null ? null : project.getModel();
+    }
+
     //
     // Implementation
     //

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
index e463079..5fdbd07 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
@@ -271,8 +271,10 @@ public class MavenSession
     {
         this.projectMap = projectMap;
     }
-
-    public Map<String, MavenProject> getProjectMap()
+    
+    @Deprecated
+    /** @deprecated This appears to only be used in the ReactorReader and we can do any processing required there */
+    public Map<String, MavenProject> getProjectMap() 
     {
         return projectMap;
     }
@@ -288,7 +290,7 @@ public class MavenSession
     {
         this.allProjects = allProjects;
     }
-
+    
     /*if_not[MAVEN4]*/
 
     //
@@ -433,5 +435,4 @@ public class MavenSession
     }   
     
     /*end[MAVEN4]*/
-    
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
new file mode 100644
index 0000000..0a602ba
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
@@ -0,0 +1,487 @@
+package org.apache.maven.graph;
+
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.DefaultMaven;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.ProjectCycleException;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.building.DefaultModelProblem;
+import org.apache.maven.model.building.ModelProblem;
+import org.apache.maven.model.building.ModelProblemUtils;
+import org.apache.maven.model.building.ModelSource;
+import org.apache.maven.model.building.Result;
+import org.apache.maven.model.building.UrlModelSource;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingResult;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+
+import com.google.common.collect.Lists;
+
+@Component( role = GraphBuilder.class, hint = GraphBuilder.HINT )
+public class DefaultGraphBuilder
+    implements GraphBuilder
+{
+    @Requirement
+    private Logger logger;
+
+    @Requirement
+    protected ProjectBuilder projectBuilder;
+
+    @Override
+    public Result<ProjectDependencyGraph> build( MavenSession session )
+    {
+        if ( session.getProjectDependencyGraph() != null )
+        {
+            return dependencyGraph( session, session.getProjects(), false );
+        }
+        
+        List<MavenProject> projects = session.getProjects();
+
+        if ( projects == null )
+        {
+            try
+            {
+                projects = getProjectsForMavenReactor( session );
+            }
+            catch ( ProjectBuildingException e )
+            {
+                return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) );
+            }
+
+            validateProjects( projects );
+
+            return dependencyGraph( session, projects, true );
+        }
+        else
+        {
+            return dependencyGraph( session, projects, false );
+        }
+    }
+    
+    private Result<ProjectDependencyGraph> dependencyGraph( MavenSession session, List<MavenProject> projects,
+                                                            boolean applyMakeBehaviour )
+    {
+        MavenExecutionRequest request = session.getRequest();
+
+        ProjectDependencyGraph projectDependencyGraph = null;
+
+        try
+        {
+            projectDependencyGraph = new DefaultProjectDependencyGraph( projects );
+
+            if ( applyMakeBehaviour )
+            {
+                List<MavenProject> activeProjects = projectDependencyGraph.getSortedProjects();
+
+                activeProjects = trimSelectedProjects( activeProjects, projectDependencyGraph, request );
+                activeProjects = trimExcludedProjects( activeProjects, request );
+                activeProjects = trimResumedProjects( activeProjects, request );
+
+                if ( activeProjects.size() != projectDependencyGraph.getSortedProjects().size() )
+                {
+                    projectDependencyGraph = new FilteredProjectDependencyGraph( projectDependencyGraph, activeProjects );
+                }
+            }
+        }
+        catch ( CycleDetectedException e )
+        {
+            String message = "The projects in the reactor contain a cyclic reference: " + e.getMessage();
+            ProjectCycleException error = new ProjectCycleException( message, e );
+            return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, error ) ) );
+        }
+        catch ( org.apache.maven.project.DuplicateProjectException e )
+        {
+            return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) );
+        }
+        catch ( MavenExecutionException e )
+        {
+            return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) );
+        }
+
+        session.setProjects( projectDependencyGraph.getSortedProjects() );
+        session.setProjectDependencyGraph( projectDependencyGraph );
+
+        return Result.success( projectDependencyGraph );
+    }
+
+    private List<MavenProject> trimSelectedProjects( List<MavenProject> projects, ProjectDependencyGraph graph,
+                                                     MavenExecutionRequest request )
+        throws MavenExecutionException
+    {
+        List<MavenProject> result = projects;
+
+        if ( !request.getSelectedProjects().isEmpty() )
+        {
+            File reactorDirectory = null;
+            if ( request.getBaseDirectory() != null )
+            {
+                reactorDirectory = new File( request.getBaseDirectory() );
+            }
+
+            Collection<MavenProject> selectedProjects = new LinkedHashSet<MavenProject>( projects.size() );
+
+            for ( String selector : request.getSelectedProjects() )
+            {
+                MavenProject selectedProject = null;
+
+                for ( MavenProject project : projects )
+                {
+                    if ( isMatchingProject( project, selector, reactorDirectory ) )
+                    {
+                        selectedProject = project;
+                        break;
+                    }
+                }
+
+                if ( selectedProject != null )
+                {
+                    selectedProjects.add( selectedProject );
+                }
+                else
+                {
+                    throw new MavenExecutionException( "Could not find the selected project in the reactor: "
+                        + selector, request.getPom() );
+                }
+            }
+
+            boolean makeUpstream = false;
+            boolean makeDownstream = false;
+
+            if ( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM.equals( request.getMakeBehavior() ) )
+            {
+                makeUpstream = true;
+            }
+            else if ( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM.equals( request.getMakeBehavior() ) )
+            {
+                makeDownstream = true;
+            }
+            else if ( MavenExecutionRequest.REACTOR_MAKE_BOTH.equals( request.getMakeBehavior() ) )
+            {
+                makeUpstream = true;
+                makeDownstream = true;
+            }
+            else if ( StringUtils.isNotEmpty( request.getMakeBehavior() ) )
+            {
+                throw new MavenExecutionException( "Invalid reactor make behavior: " + request.getMakeBehavior(),
+                                                   request.getPom() );
+            }
+
+            if ( makeUpstream || makeDownstream )
+            {
+                for ( MavenProject selectedProject : new ArrayList<MavenProject>( selectedProjects ) )
+                {
+                    if ( makeUpstream )
+                    {
+                        selectedProjects.addAll( graph.getUpstreamProjects( selectedProject, true ) );
+                    }
+                    if ( makeDownstream )
+                    {
+                        selectedProjects.addAll( graph.getDownstreamProjects( selectedProject, true ) );
+                    }
+                }
+            }
+
+            result = new ArrayList<MavenProject>( selectedProjects.size() );
+
+            for ( MavenProject project : projects )
+            {
+                if ( selectedProjects.contains( project ) )
+                {
+                    result.add( project );
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private List<MavenProject> trimExcludedProjects( List<MavenProject> projects, MavenExecutionRequest request )
+        throws MavenExecutionException
+    {
+        List<MavenProject> result = projects;
+
+        if ( !request.getExcludedProjects().isEmpty() )
+        {
+            File reactorDirectory = null;
+
+            if ( request.getBaseDirectory() != null )
+            {
+                reactorDirectory = new File( request.getBaseDirectory() );
+            }
+
+            Collection<MavenProject> excludedProjects = new LinkedHashSet<MavenProject>( projects.size() );
+
+            for ( String selector : request.getExcludedProjects() )
+            {
+                MavenProject excludedProject = null;
+
+                for ( MavenProject project : projects )
+                {
+                    if ( isMatchingProject( project, selector, reactorDirectory ) )
+                    {
+                        excludedProject = project;
+                        break;
+                    }
+                }
+
+                if ( excludedProject != null )
+                {
+                    excludedProjects.add( excludedProject );
+                }
+                else
+                {
+                    throw new MavenExecutionException( "Could not find the selected project in the reactor: "
+                        + selector, request.getPom() );
+                }
+            }
+
+            result = new ArrayList<MavenProject>( projects.size() );
+            for ( MavenProject project : projects )
+            {
+                if ( !excludedProjects.contains( project ) )
+                {
+                    result.add( project );
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private List<MavenProject> trimResumedProjects( List<MavenProject> projects, MavenExecutionRequest request )
+        throws MavenExecutionException
+    {
+        List<MavenProject> result = projects;
+
+        if ( StringUtils.isNotEmpty( request.getResumeFrom() ) )
+        {
+            File reactorDirectory = null;
+            if ( request.getBaseDirectory() != null )
+            {
+                reactorDirectory = new File( request.getBaseDirectory() );
+            }
+
+            String selector = request.getResumeFrom();
+
+            result = new ArrayList<MavenProject>( projects.size() );
+
+            boolean resumed = false;
+
+            for ( MavenProject project : projects )
+            {
+                if ( !resumed && isMatchingProject( project, selector, reactorDirectory ) )
+                {
+                    resumed = true;
+                }
+
+                if ( resumed )
+                {
+                    result.add( project );
+                }
+            }
+
+            if ( !resumed )
+            {
+                throw new MavenExecutionException( "Could not find project to resume reactor build from: " + selector
+                    + " vs " + projects, request.getPom() );
+            }
+        }
+
+        return result;
+    }
+
+    private boolean isMatchingProject( MavenProject project, String selector, File reactorDirectory )
+    {
+        // [groupId]:artifactId
+        if ( selector.indexOf( ':' ) >= 0 )
+        {
+            String id = ':' + project.getArtifactId();
+
+            if ( id.equals( selector ) )
+            {
+                return true;
+            }
+
+            id = project.getGroupId() + id;
+
+            if ( id.equals( selector ) )
+            {
+                return true;
+            }
+        }
+
+        // relative path, e.g. "sub", "../sub" or "."
+        else if ( reactorDirectory != null )
+        {
+            File selectedProject = new File( new File( reactorDirectory, selector ).toURI().normalize() );
+
+            if ( selectedProject.isFile() )
+            {
+                return selectedProject.equals( project.getFile() );
+            }
+            else if ( selectedProject.isDirectory() )
+            {
+                return selectedProject.equals( project.getBasedir() );
+            }
+        }
+
+        return false;
+    }
+
+    private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, Throwable e )
+    {
+        if ( !result.getExceptions().contains( e ) )
+        {
+            result.addException( e );
+        }
+
+        return result;
+    }
+
+    // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Project collection
+    //
+    // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private List<MavenProject> getProjectsForMavenReactor( MavenSession session )
+        throws ProjectBuildingException
+    {
+        MavenExecutionRequest request = session.getRequest();
+
+        request.getProjectBuildingRequest().setRepositorySession( session.getRepositorySession() );
+
+        List<MavenProject> projects = new ArrayList<MavenProject>();
+
+        // We have no POM file.
+        //
+        if ( request.getPom() == null )
+        {
+            ModelSource modelSource = new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) );
+            MavenProject project = projectBuilder.build( modelSource, request.getProjectBuildingRequest() )
+                .getProject();
+            project.setExecutionRoot( true );
+            projects.add( project );
+            request.setProjectPresent( false );
+            return projects;
+        }
+
+        List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
+        collectProjects( projects, files, request );
+        return projects;
+    }
+
+    private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
+        throws ProjectBuildingException
+    {
+        ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
+
+        List<ProjectBuildingResult> results = projectBuilder.build( files, request.isRecursive(),
+                                                                    projectBuildingRequest );
+
+        boolean problems = false;
+
+        for ( ProjectBuildingResult result : results )
+        {
+            projects.add( result.getProject() );
+
+            if ( !result.getProblems().isEmpty() && logger.isWarnEnabled() )
+            {
+                logger.warn( "" );
+                logger.warn( "Some problems were encountered while building the effective model for "
+                    + result.getProject().getId() );
+
+                for ( ModelProblem problem : result.getProblems() )
+                {
+                    String loc = ModelProblemUtils.formatLocation( problem, result.getProjectId() );
+                    logger.warn( problem.getMessage() + ( StringUtils.isNotEmpty( loc ) ? " @ " + loc : "" ) );
+                }
+
+                problems = true;
+            }
+        }
+
+        if ( problems )
+        {
+            logger.warn( "" );
+            logger.warn( "It is highly recommended to fix these problems"
+                + " because they threaten the stability of your build." );
+            logger.warn( "" );
+            logger.warn( "For this reason, future Maven versions might no"
+                + " longer support building such malformed projects." );
+            logger.warn( "" );
+        }
+    }
+
+    private void validateProjects( List<MavenProject> projects )
+    {
+        Map<String, MavenProject> projectsMap = new HashMap<String, MavenProject>();
+
+        for ( MavenProject p : projects )
+        {
+            String projectKey = ArtifactUtils.key( p.getGroupId(), p.getArtifactId(), p.getVersion() );
+
+            projectsMap.put( projectKey, p );
+        }
+
+        for ( MavenProject project : projects )
+        {
+            // MNG-1911 / MNG-5572: Building plugins with extensions cannot be part of reactor
+            for ( Plugin plugin : project.getBuildPlugins() )
+            {
+                if ( plugin.isExtensions() )
+                {
+                    String pluginKey = ArtifactUtils.key( plugin.getGroupId(), plugin.getArtifactId(),
+                                                          plugin.getVersion() );
+
+                    if ( projectsMap.containsKey( pluginKey ) )
+                    {
+                        logger.warn( project.getName() + " uses " + plugin.getKey()
+                            + " as extensions, which is not possible within the same reactor build. "
+                            + "This plugin was pulled from the local repository!" );
+                    }
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java
new file mode 100644
index 0000000..01fec33
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java
@@ -0,0 +1,134 @@
+package org.apache.maven.graph;
+
+/*
+ * 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.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.project.DuplicateProjectException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectSorter;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+
+/**
+ * Describes the inter-dependencies between projects in the reactor.
+ *
+ * @author Benjamin Bentmann
+ */
+public class DefaultProjectDependencyGraph
+    implements ProjectDependencyGraph
+{
+
+    private ProjectSorter sorter;
+
+    /**
+     * Creates a new project dependency graph based on the specified projects.
+     *
+     * @param projects The projects to create the dependency graph with
+     * @throws DuplicateProjectException
+     * @throws CycleDetectedException
+     */
+    public DefaultProjectDependencyGraph( Collection<MavenProject> projects )
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        this.sorter = new ProjectSorter( projects );
+    }
+
+    public List<MavenProject> getSortedProjects()
+    {
+        return new ArrayList<MavenProject>( sorter.getSortedProjects() );
+    }
+
+    public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
+    {
+        if ( project == null )
+        {
+            throw new IllegalArgumentException( "project missing" );
+        }
+
+        Set<String> projectIds = new HashSet<String>();
+
+        getDownstreamProjects( ProjectSorter.getId( project ), projectIds, transitive );
+
+        return getSortedProjects( projectIds );
+    }
+
+    private void getDownstreamProjects( String projectId, Set<String> projectIds, boolean transitive )
+    {
+        for ( String id : sorter.getDependents( projectId ) )
+        {
+            if ( projectIds.add( id ) && transitive )
+            {
+                getDownstreamProjects( id, projectIds, transitive );
+            }
+        }
+    }
+
+    public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
+    {
+        if ( project == null )
+        {
+            throw new IllegalArgumentException( "project missing" );
+        }
+
+        Set<String> projectIds = new HashSet<String>();
+
+        getUpstreamProjects( ProjectSorter.getId( project ), projectIds, transitive );
+
+        return getSortedProjects( projectIds );
+    }
+
+    private void getUpstreamProjects( String projectId, Collection<String> projectIds, boolean transitive )
+    {
+        for ( String id : sorter.getDependencies( projectId ) )
+        {
+            if ( projectIds.add( id ) && transitive )
+            {
+                getUpstreamProjects( id, projectIds, transitive );
+            }
+        }
+    }
+
+    private List<MavenProject> getSortedProjects( Set<String> projectIds )
+    {
+        List<MavenProject> result = new ArrayList<MavenProject>( projectIds.size() );
+
+        for ( MavenProject mavenProject : sorter.getSortedProjects() )
+        {
+            if ( projectIds.contains( ProjectSorter.getId( mavenProject ) ) )
+            {
+                result.add( mavenProject );
+            }
+        }
+
+        return result;
+    }
+
+    @Override
+    public String toString()
+    {
+        return sorter.getSortedProjects().toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java
new file mode 100644
index 0000000..662bda4
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java
@@ -0,0 +1,111 @@
+package org.apache.maven.graph;
+
+/*
+ * 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.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Provides a sub view of another dependency graph.
+ *
+ * @author Benjamin Bentmann
+ */
+class FilteredProjectDependencyGraph
+    implements ProjectDependencyGraph
+{
+
+    private ProjectDependencyGraph projectDependencyGraph;
+
+    private Map<MavenProject, ?> whiteList;
+
+    private List<MavenProject> sortedProjects;
+
+    /**
+     * Creates a new project dependency graph from the specified graph.
+     *
+     * @param projectDependencyGraph The project dependency graph to create a sub view from, must not be {@code null}.
+     * @param whiteList The projects on which the dependency view should focus, must not be {@code null}.
+     */
+    public FilteredProjectDependencyGraph( ProjectDependencyGraph projectDependencyGraph,
+                                           Collection<? extends MavenProject> whiteList )
+    {
+        if ( projectDependencyGraph == null )
+        {
+            throw new IllegalArgumentException( "project dependency graph missing" );
+        }
+
+        this.projectDependencyGraph = projectDependencyGraph;
+
+        this.whiteList = new IdentityHashMap<MavenProject, Object>();
+
+        for ( MavenProject project : whiteList )
+        {
+            this.whiteList.put( project, null );
+        }
+    }
+
+    public List<MavenProject> getSortedProjects()
+    {
+        if ( sortedProjects == null )
+        {
+            sortedProjects = applyFilter( projectDependencyGraph.getSortedProjects() );
+        }
+
+        return new ArrayList<MavenProject>( sortedProjects );
+    }
+
+    public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
+    {
+        return applyFilter( projectDependencyGraph.getDownstreamProjects( project, transitive ) );
+    }
+
+    public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
+    {
+        return applyFilter( projectDependencyGraph.getUpstreamProjects( project, transitive ) );
+    }
+
+    private List<MavenProject> applyFilter( Collection<? extends MavenProject> projects )
+    {
+        List<MavenProject> filtered = new ArrayList<MavenProject>( projects.size() );
+
+        for ( MavenProject project : projects )
+        {
+            if ( whiteList.containsKey( project ) )
+            {
+                filtered.add( project );
+            }
+        }
+
+        return filtered;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getSortedProjects().toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java
new file mode 100644
index 0000000..fb7c4f2
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java
@@ -0,0 +1,31 @@
+package org.apache.maven.graph;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.model.building.Result;
+
+public interface GraphBuilder
+{
+    String HINT = "graphBuilder";
+
+    Result<? extends ProjectDependencyGraph> build( MavenSession session );
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
index 262cf09..a536562 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
@@ -37,7 +37,7 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
  *
  * @author Benjamin Bentmann
  */
-class DefaultModelBuildingListener
+public class DefaultModelBuildingListener
     extends AbstractModelBuildingListener
 {
 

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index 641ebda..a14aaa1 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -1171,7 +1171,7 @@ public class MavenProject
         return clone;
     }
 
-    protected void setModel( Model model )
+    public void setModel( Model model )
     {
         this.model = model;
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index c64dd73..77e7c49 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -28,6 +28,7 @@ import java.util.Set;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
+
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.Repository;
 import org.apache.maven.model.building.FileModelSource;
@@ -55,7 +56,7 @@ import org.eclipse.aether.resolution.VersionRangeResult;
  *
  * @author Benjamin Bentmann
  */
-class ProjectModelResolver
+public class ProjectModelResolver
     implements ModelResolver
 {
 

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/test/java/org/apache/maven/DefaultProjectDependencyGraphTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/DefaultProjectDependencyGraphTest.java b/maven-core/src/test/java/org/apache/maven/DefaultProjectDependencyGraphTest.java
deleted file mode 100644
index 668dafb..0000000
--- a/maven-core/src/test/java/org/apache/maven/DefaultProjectDependencyGraphTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.maven;
-
-import junit.framework.TestCase;
-import org.apache.maven.execution.ProjectDependencyGraph;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.project.DuplicateProjectException;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.dag.CycleDetectedException;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Kristian Rosenvold
- */
-public class DefaultProjectDependencyGraphTest
-    extends TestCase
-{
-
-    private final MavenProject aProject = createA();
-
-    private final MavenProject depender1 = createProject( Arrays.asList( toDependency( aProject ) ), "depender1" );
-
-    private final MavenProject depender2 = createProject( Arrays.asList( toDependency( aProject ) ), "depender2" );
-
-    private final MavenProject depender3 = createProject( Arrays.asList( toDependency( aProject ) ), "depender3" );
-
-    private final MavenProject depender4 =
-        createProject( Arrays.asList( toDependency( aProject ), toDependency( depender3 ) ), "depender4" );
-
-    private final MavenProject transitiveOnly =
-        createProject( Arrays.asList( toDependency( depender3 ) ), "depender5" );
-
-    public void testGetSortedProjects()
-        throws DuplicateProjectException, CycleDetectedException
-    {
-        ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, aProject ) );
-        final List<MavenProject> sortedProjects = graph.getSortedProjects();
-        assertEquals( aProject, sortedProjects.get( 0 ) );
-        assertEquals( depender1, sortedProjects.get( 1 ) );
-    }
-
-    public void testVerifyExpectedParentStructure()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        // This test verifies the baseline structure used in susequent tests. If this fails, the rest will fail.
-        ProjectDependencyGraph graph = threeProjectsDependingOnASingle();
-        final List<MavenProject> sortedProjects = graph.getSortedProjects();
-        assertEquals( aProject, sortedProjects.get( 0 ) );
-        assertEquals( depender1, sortedProjects.get( 1 ) );
-        assertEquals( depender2, sortedProjects.get( 2 ) );
-        assertEquals( depender3, sortedProjects.get( 3 ) );
-    }
-
-    public void testVerifyThatDownsteamProjectsComeInSortedOrder()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        final List<MavenProject> downstreamProjects =
-            threeProjectsDependingOnASingle().getDownstreamProjects( aProject, true );
-        assertEquals( depender1, downstreamProjects.get( 0 ) );
-        assertEquals( depender2, downstreamProjects.get( 1 ) );
-        assertEquals( depender3, downstreamProjects.get( 2 ) );
-    }
-
-    public void testTransitivesInOrder()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        final ProjectDependencyGraph graph =
-            new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) );
-
-        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true );
-        assertEquals( depender1, downstreamProjects.get( 0 ) );
-        assertEquals( depender3, downstreamProjects.get( 1 ) );
-        assertEquals( depender4, downstreamProjects.get( 2 ) );
-        assertEquals( depender2, downstreamProjects.get( 3 ) );
-    }
-
-    public void testNonTransitivesInOrder()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        final ProjectDependencyGraph graph =
-            new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) );
-
-        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false );
-        assertEquals( depender1, downstreamProjects.get( 0 ) );
-        assertEquals( depender3, downstreamProjects.get( 1 ) );
-        assertEquals( depender4, downstreamProjects.get( 2 ) );
-        assertEquals( depender2, downstreamProjects.get( 3 ) );
-    }
-
-    public void testWithTranistiveOnly()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph(
-            Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) );
-
-        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true );
-        assertEquals( depender1, downstreamProjects.get( 0 ) );
-        assertEquals( depender3, downstreamProjects.get( 1 ) );
-        assertEquals( transitiveOnly, downstreamProjects.get( 2 ) );
-        assertEquals( depender2, downstreamProjects.get( 3 ) );
-    }
-
-    public void testWithMissingTranistiveOnly()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph(
-            Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) );
-
-        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false );
-        assertEquals( depender1, downstreamProjects.get( 0 ) );
-        assertEquals( depender3, downstreamProjects.get( 1 ) );
-        assertEquals( depender2, downstreamProjects.get( 2 ) );
-    }
-
-    public void testGetUpstreamProjects()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        ProjectDependencyGraph graph = threeProjectsDependingOnASingle();
-        final List<MavenProject> downstreamProjects = graph.getUpstreamProjects( depender1, true );
-        assertEquals( aProject, downstreamProjects.get( 0 ) );
-    }
-
-    private ProjectDependencyGraph threeProjectsDependingOnASingle()
-        throws CycleDetectedException, DuplicateProjectException
-    {
-        return new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender2, depender3, aProject ) );
-    }
-
-    private static MavenProject createA()
-    {
-        MavenProject result = new MavenProject();
-        result.setGroupId( "org.apache" );
-        result.setArtifactId( "A" );
-        result.setVersion( "1.2" );
-        return result;
-    }
-
-    static Dependency toDependency( MavenProject mavenProject )
-    {
-        final Dependency dependency = new Dependency();
-        dependency.setArtifactId( mavenProject.getArtifactId() );
-        dependency.setGroupId( mavenProject.getGroupId() );
-        dependency.setVersion( mavenProject.getVersion() );
-        return dependency;
-    }
-
-    private static MavenProject createProject( List<Dependency> dependencies, String artifactId )
-    {
-        MavenProject result = new MavenProject();
-        result.setGroupId( "org.apache" );
-        result.setArtifactId( artifactId );
-        result.setVersion( "1.2" );
-        result.setDependencies( dependencies );
-        return result;
-    }
-
-}
\ No newline at end of file


Re: [1/3] maven git commit: MNG-5774 Provide an extension point for alternate CLI configuration source

Posted by Robert Scholte <rf...@apache.org>.
Op Sun, 01 Mar 2015 22:34:39 +0100 schreef <jv...@apache.org>:

> @@ -132,11 +130,6 @@ public class MavenCli
>      @SuppressWarnings( "checkstyle:constantname" )
>      public static final File userMavenConfigurationHome = new File(  
> userHome, ".m2" );
> -    public static final File DEFAULT_USER_SETTINGS_FILE = new File(  
> userMavenConfigurationHome, "settings.xml" );
> -
> -    public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
> -        new File( System.getProperty( "maven.home", System.getProperty(  
> "user.dir", "" ) ), "conf/settings.xml" );
> -
>      public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File(  
> userMavenConfigurationHome, "toolchains.xml" );
>     public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =

I'm pretty sure there are plugins which depend on these fields. Just  
removing them will make the plugins incompatible with the next releases of  
Maven. Why not mark them as deprecates and set them to  
SettingsXmlConfigurationProcessor.DEFAULT_X_SETTINGS_FILE

thanks,
Robert

[2/3] maven git commit: MNG-5775 Make the project graph building code pluggable to allow for new/different implementations.

Posted by jv...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java b/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java
new file mode 100644
index 0000000..e2caaeb
--- /dev/null
+++ b/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.maven.graph;
+
+import junit.framework.TestCase;
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.project.DuplicateProjectException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class DefaultProjectDependencyGraphTest
+    extends TestCase
+{
+
+    private final MavenProject aProject = createA();
+
+    private final MavenProject depender1 = createProject( Arrays.asList( toDependency( aProject ) ), "depender1" );
+
+    private final MavenProject depender2 = createProject( Arrays.asList( toDependency( aProject ) ), "depender2" );
+
+    private final MavenProject depender3 = createProject( Arrays.asList( toDependency( aProject ) ), "depender3" );
+
+    private final MavenProject depender4 =
+        createProject( Arrays.asList( toDependency( aProject ), toDependency( depender3 ) ), "depender4" );
+
+    private final MavenProject transitiveOnly =
+        createProject( Arrays.asList( toDependency( depender3 ) ), "depender5" );
+
+    public void testGetSortedProjects()
+        throws DuplicateProjectException, CycleDetectedException
+    {
+        ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, aProject ) );
+        final List<MavenProject> sortedProjects = graph.getSortedProjects();
+        assertEquals( aProject, sortedProjects.get( 0 ) );
+        assertEquals( depender1, sortedProjects.get( 1 ) );
+    }
+
+    public void testVerifyExpectedParentStructure()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        // This test verifies the baseline structure used in susequent tests. If this fails, the rest will fail.
+        ProjectDependencyGraph graph = threeProjectsDependingOnASingle();
+        final List<MavenProject> sortedProjects = graph.getSortedProjects();
+        assertEquals( aProject, sortedProjects.get( 0 ) );
+        assertEquals( depender1, sortedProjects.get( 1 ) );
+        assertEquals( depender2, sortedProjects.get( 2 ) );
+        assertEquals( depender3, sortedProjects.get( 3 ) );
+    }
+
+    public void testVerifyThatDownsteamProjectsComeInSortedOrder()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        final List<MavenProject> downstreamProjects =
+            threeProjectsDependingOnASingle().getDownstreamProjects( aProject, true );
+        assertEquals( depender1, downstreamProjects.get( 0 ) );
+        assertEquals( depender2, downstreamProjects.get( 1 ) );
+        assertEquals( depender3, downstreamProjects.get( 2 ) );
+    }
+
+    public void testTransitivesInOrder()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        final ProjectDependencyGraph graph =
+            new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) );
+
+        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true );
+        assertEquals( depender1, downstreamProjects.get( 0 ) );
+        assertEquals( depender3, downstreamProjects.get( 1 ) );
+        assertEquals( depender4, downstreamProjects.get( 2 ) );
+        assertEquals( depender2, downstreamProjects.get( 3 ) );
+    }
+
+    public void testNonTransitivesInOrder()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        final ProjectDependencyGraph graph =
+            new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) );
+
+        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false );
+        assertEquals( depender1, downstreamProjects.get( 0 ) );
+        assertEquals( depender3, downstreamProjects.get( 1 ) );
+        assertEquals( depender4, downstreamProjects.get( 2 ) );
+        assertEquals( depender2, downstreamProjects.get( 3 ) );
+    }
+
+    public void testWithTranistiveOnly()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph(
+            Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) );
+
+        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true );
+        assertEquals( depender1, downstreamProjects.get( 0 ) );
+        assertEquals( depender3, downstreamProjects.get( 1 ) );
+        assertEquals( transitiveOnly, downstreamProjects.get( 2 ) );
+        assertEquals( depender2, downstreamProjects.get( 3 ) );
+    }
+
+    public void testWithMissingTranistiveOnly()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph(
+            Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) );
+
+        final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false );
+        assertEquals( depender1, downstreamProjects.get( 0 ) );
+        assertEquals( depender3, downstreamProjects.get( 1 ) );
+        assertEquals( depender2, downstreamProjects.get( 2 ) );
+    }
+
+    public void testGetUpstreamProjects()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        ProjectDependencyGraph graph = threeProjectsDependingOnASingle();
+        final List<MavenProject> downstreamProjects = graph.getUpstreamProjects( depender1, true );
+        assertEquals( aProject, downstreamProjects.get( 0 ) );
+    }
+
+    private ProjectDependencyGraph threeProjectsDependingOnASingle()
+        throws CycleDetectedException, DuplicateProjectException
+    {
+        return new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender2, depender3, aProject ) );
+    }
+
+    private static MavenProject createA()
+    {
+        MavenProject result = new MavenProject();
+        result.setGroupId( "org.apache" );
+        result.setArtifactId( "A" );
+        result.setVersion( "1.2" );
+        return result;
+    }
+
+    static Dependency toDependency( MavenProject mavenProject )
+    {
+        final Dependency dependency = new Dependency();
+        dependency.setArtifactId( mavenProject.getArtifactId() );
+        dependency.setGroupId( mavenProject.getGroupId() );
+        dependency.setVersion( mavenProject.getVersion() );
+        return dependency;
+    }
+
+    private static MavenProject createProject( List<Dependency> dependencies, String artifactId )
+    {
+        MavenProject result = new MavenProject();
+        result.setGroupId( "org.apache" );
+        result.setArtifactId( artifactId );
+        result.setVersion( "1.2" );
+        result.setDependencies( dependencies );
+        return result;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
index 04be08b..99b07e3 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
@@ -409,6 +409,11 @@ public class LifecycleExecutorTest
             {
                 return Collections.emptyList();
             }
+            
+            public java.util.List<MavenProject> getAllSortedProjects()
+            {
+                return Collections.emptyList();
+            }
         } );
 
         final List<String> log = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml
index 738f64f..186e207 100644
--- a/maven-model-builder/pom.xml
+++ b/maven-model-builder/pom.xml
@@ -51,7 +51,10 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-builder-support</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.eclipse.sisu</groupId>
       <artifactId>org.eclipse.sisu.plexus</artifactId>

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 80effb1..52b3c9c 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -19,6 +19,10 @@ package org.apache.maven.model.building;
  * under the License.
  */
 
+
+import static org.apache.maven.model.building.Result.error;
+import static org.apache.maven.model.building.Result.newResult;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -63,6 +67,7 @@ import org.apache.maven.model.profile.ProfileSelector;
 import org.apache.maven.model.resolution.InvalidRepositoryException;
 import org.apache.maven.model.resolution.ModelResolver;
 import org.apache.maven.model.resolution.UnresolvableModelException;
+import org.apache.maven.model.resolution.WorkspaceModelResolver;
 import org.apache.maven.model.superpom.SuperPomProvider;
 import org.apache.maven.model.validation.ModelValidator;
 import org.codehaus.plexus.component.annotations.Component;
@@ -241,8 +246,8 @@ public class DefaultModelBuilder
         DefaultProfileActivationContext profileActivationContext = getProfileActivationContext( request );
 
         problems.setSource( "(external profiles)" );
-        List<Profile> activeExternalProfiles =
-            profileSelector.getActiveProfiles( request.getProfiles(), profileActivationContext, problems );
+        List<Profile> activeExternalProfiles = profileSelector.getActiveProfiles( request.getProfiles(),
+                                                                                  profileActivationContext, problems );
 
         result.setActiveExternalProfiles( activeExternalProfiles );
 
@@ -258,7 +263,11 @@ public class DefaultModelBuilder
         }
 
         // read and validate raw model
-        Model inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems );
+        Model inputModel = request.getRawModel();
+        if ( inputModel == null )
+        {
+            inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems );
+        }
 
         problems.setRootModel( inputModel );
 
@@ -272,11 +281,12 @@ public class DefaultModelBuilder
         {
             lineage.add( currentData );
 
-            Model tmpModel = currentData.getModel();
-
-            Model rawModel = tmpModel.clone();
+            Model rawModel = currentData.getModel();
             currentData.setRawModel( rawModel );
 
+            Model tmpModel = rawModel.clone();
+            currentData.setModel( tmpModel );
+
             problems.setSource( tmpModel );
 
             // model normalization
@@ -284,8 +294,8 @@ public class DefaultModelBuilder
 
             profileActivationContext.setProjectProperties( tmpModel.getProperties() );
 
-            List<Profile> activePomProfiles =
-                profileSelector.getActiveProfiles( rawModel.getProfiles(), profileActivationContext, problems );
+            List<Profile> activePomProfiles = profileSelector.getActiveProfiles( rawModel.getProfiles(),
+                                                                                 profileActivationContext, problems );
             currentData.setActiveProfiles( activePomProfiles );
 
             Map<String, Activation> interpolatedActivations = getProfileActivations( rawModel, false );
@@ -320,13 +330,13 @@ public class DefaultModelBuilder
             }
             else if ( currentData == resultData )
             { // First iteration - add initial parent id after version resolution.
-                currentData.setGroupId( currentData.getRawModel().getGroupId() == null
-                                            ? parentData.getGroupId()
-                                            : currentData.getRawModel().getGroupId() );
+                currentData.setGroupId( currentData.getRawModel().getGroupId() == null ? parentData.getGroupId()
+                                                                                      : currentData.getRawModel()
+                                                                                          .getGroupId() );
 
-                currentData.setVersion( currentData.getRawModel().getVersion() == null
-                                            ? parentData.getVersion()
-                                            : currentData.getRawModel().getVersion() );
+                currentData.setVersion( currentData.getRawModel().getVersion() == null ? parentData.getVersion()
+                                                                                      : currentData.getRawModel()
+                                                                                          .getVersion() );
 
                 currentData.setArtifactId( currentData.getRawModel().getArtifactId() );
                 parentIds.add( currentData.getId() );
@@ -345,9 +355,8 @@ public class DefaultModelBuilder
                 }
                 message += parentData.getId();
 
-                problems.add(
-                    new ModelProblemCollectorRequest( ModelProblem.Severity.FATAL, ModelProblem.Version.BASE ).
-                    setMessage( message ) );
+                problems.add( new ModelProblemCollectorRequest( ModelProblem.Severity.FATAL, ModelProblem.Version.BASE )
+                    .setMessage( message ) );
 
                 throw problems.newModelBuildingException();
             }
@@ -376,7 +385,7 @@ public class DefaultModelBuilder
         modelUrlNormalizer.normalize( resultModel, request );
 
         // Now the fully interpolated model is available: reconfigure the resolver
-        configureResolver( request.getModelResolver(), resultModel, problems , true );
+        configureResolver( request.getModelResolver(), resultModel, problems, true );
 
         resultData.setGroupId( resultModel.getGroupId() );
         resultData.setArtifactId( resultModel.getArtifactId() );
@@ -469,6 +478,23 @@ public class DefaultModelBuilder
         return result;
     }
 
+    @Override
+    public Result<? extends Model> buildRawModel( File pomFile, int validationLevel, boolean locationTracking )
+    {
+        final ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( validationLevel )
+            .setLocationTracking( locationTracking );
+        final DefaultModelProblemCollector collector = 
+            new DefaultModelProblemCollector( new DefaultModelBuildingResult() );
+        try
+        {
+            return newResult( readModel( null, pomFile, request, collector ), collector.getProblems() );
+        }
+        catch ( ModelBuildingException e )
+        {
+            return error( collector.getProblems() );
+        }
+    }
+
     private Model readModel( ModelSource modelSource, File pomFile, ModelBuildingRequest request,
                              DefaultModelProblemCollector problems )
         throws ModelBuildingException
@@ -524,14 +550,14 @@ public class DefaultModelBuilder
                 if ( pomFile != null )
                 {
                     problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.V20 )
-                            .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
-                            .setException( e ) );
+                        .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
+                        .setException( e ) );
                 }
                 else
                 {
                     problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 )
-                            .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
-                            .setException( e ) );
+                        .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
+                        .setException( e ) );
                 }
             }
 
@@ -544,8 +570,8 @@ public class DefaultModelBuilder
         catch ( ModelParseException e )
         {
             problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
-                    .setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() )
-                    .setException( e ) );
+                .setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() )
+                .setException( e ) );
             throw problems.newModelBuildingException();
         }
         catch ( IOException e )
@@ -564,8 +590,7 @@ public class DefaultModelBuilder
                 }
             }
             problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
-                    .setMessage( "Non-readable POM " + modelSource.getLocation() + ": " + msg )
-                    .setException( e ) );
+                .setMessage( "Non-readable POM " + modelSource.getLocation() + ": " + msg ).setException( e ) );
             throw problems.newModelBuildingException();
         }
 
@@ -621,9 +646,8 @@ public class DefaultModelBuilder
             catch ( InvalidRepositoryException e )
             {
                 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                        .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage() )
-                        .setLocation( repository.getLocation( "" ) )
-                        .setException( e ) );
+                    .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage() )
+                    .setLocation( repository.getLocation( "" ) ).setException( e ) );
             }
         }
     }
@@ -675,7 +699,8 @@ public class DefaultModelBuilder
             if ( versions.get( key ) == null && managedVersions.get( key ) == null )
             {
                 InputLocation location = plugins.get( key ).getLocation( "" );
-                problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 )
+                problems
+                    .add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 )
                         .setMessage( "'build.plugins.plugin.version' for " + key + " is missing." )
                         .setLocation( location ) );
             }
@@ -800,9 +825,9 @@ public class DefaultModelBuilder
             if ( !"pom".equals( parentModel.getPackaging() ) )
             {
                 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                        .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel )
+                    .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel )
                                      + ", must be \"pom\" but is \"" + parentModel.getPackaging() + "\"" )
-                        .setLocation( parentModel.getLocation( "packaging" ) ) );
+                    .setLocation( parentModel.getLocation( "packaging" ) ) );
             }
         }
         else
@@ -817,20 +842,52 @@ public class DefaultModelBuilder
                                          DefaultModelProblemCollector problems )
         throws ModelBuildingException
     {
-        ModelSource candidateSource = getParentPomFile( childModel, childSource );
-
-        if ( candidateSource == null )
+        final Parent parent = childModel.getParent();
+        final ModelSource candidateSource;
+        final Model candidateModel;
+        final WorkspaceModelResolver resolver = request.getWorkspaceModelResolver();
+        if ( resolver == null )
         {
-            return null;
-        }
+            candidateSource = getParentPomFile( childModel, childSource );
+
+            if ( candidateSource == null )
+            {
+                return null;
+            }
+
+            File pomFile = null;
+            if ( candidateSource instanceof FileModelSource )
+            {
+                pomFile = ( (FileModelSource) candidateSource ).getPomFile();
+            }
 
-        File pomFile = null;
-        if ( candidateSource instanceof FileModelSource )
+            candidateModel = readModel( candidateSource, pomFile, request, problems );
+        }
+        else
         {
-            pomFile = ( (FileModelSource) candidateSource ).getPomFile();
+            try
+            {
+                candidateModel =
+                    resolver.resolveRawModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
+            }
+            catch ( UnresolvableModelException e )
+            {
+                problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) //
+                .setMessage( e.getMessage().toString() ).setLocation( parent.getLocation( "" ) ).setException( e ) );
+                throw problems.newModelBuildingException();
+            }
+            if ( candidateModel == null )
+            {
+                return null;
+            }
+            candidateSource = new FileModelSource( candidateModel.getPomFile() );
         }
 
-        Model candidateModel = readModel( candidateSource, pomFile, request, problems );
+        //
+        // TODO:jvz Why isn't all this checking the job of the duty of the workspace resolver, we know that we
+        // have a model that is suitable, yet more checks are done here and the one for the version is problematic
+        // before because with parents as ranges it will never work in this scenario.
+        //
 
         String groupId = candidateModel.getGroupId();
         if ( groupId == null && candidateModel.getParent() != null )
@@ -844,8 +901,6 @@ public class DefaultModelBuilder
             version = candidateModel.getParent().getVersion();
         }
 
-        Parent parent = childModel.getParent();
-
         if ( groupId == null || !groupId.equals( parent.getGroupId() ) || artifactId == null
             || !artifactId.equals( parent.getArtifactId() ) )
         {
@@ -861,15 +916,19 @@ public class DefaultModelBuilder
 
             problems.setSource( childModel );
             problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE )
-                    .setMessage( buffer.toString() )
-                    .setLocation( parent.getLocation( "" ) ) );
-            return null;
-        }
-        if ( version == null || !version.equals( parent.getVersion() ) )
-        {
+                .setMessage( buffer.toString() ).setLocation( parent.getLocation( "" ) ) );
             return null;
         }
 
+        //
+        // Here we just need to know that a version is fine to use but this validation we can do in our workspace
+        // resolver.
+        //
+
+        /*
+         * if ( version == null || !version.equals( parent.getVersion() ) ) { return null; }
+         */
+
         ModelData parentData = new ModelData( candidateSource, candidateModel, groupId, artifactId, version );
 
         return parentData;
@@ -944,9 +1003,7 @@ public class DefaultModelBuilder
             }
 
             problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
-                    .setMessage( buffer.toString() )
-                    .setLocation( parent.getLocation( "" ) )
-                    .setException( e ) );
+                .setMessage( buffer.toString() ).setLocation( parent.getLocation( "" ) ).setException( e ) );
             throw problems.newModelBuildingException();
         }
 
@@ -969,18 +1026,17 @@ public class DefaultModelBuilder
         {
             if ( childModel.getVersion() == null )
             {
-                problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ).
-                    setMessage( "Version must be a constant" ).
-                    setLocation( childModel.getLocation( "" ) ) );
+                problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 )
+                    .setMessage( "Version must be a constant" ).setLocation( childModel.getLocation( "" ) ) );
 
             }
             else
             {
                 if ( childModel.getVersion().indexOf( "${" ) > -1 )
                 {
-                    problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ).
-                        setMessage( "Version must be a constant" ).
-                        setLocation( childModel.getLocation( "version" ) ) );
+                    problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 )
+                        .setMessage( "Version must be a constant" )
+                        .setLocation( childModel.getLocation( "version" ) ) );
 
                 }
             }
@@ -1013,7 +1069,8 @@ public class DefaultModelBuilder
 
         importIds.add( importing );
 
-        ModelResolver modelResolver = request.getModelResolver();
+        final WorkspaceModelResolver workspaceResolver = request.getWorkspaceModelResolver();
+        final ModelResolver modelResolver = request.getModelResolver();
 
         ModelBuildingRequest importRequest = null;
 
@@ -1037,25 +1094,25 @@ public class DefaultModelBuilder
             if ( groupId == null || groupId.length() <= 0 )
             {
                 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                        .setMessage( "'dependencyManagement.dependencies.dependency.groupId' for "
-                                        + dependency.getManagementKey() + " is missing." )
-                        .setLocation( dependency.getLocation( "" ) ) );
+                    .setMessage( "'dependencyManagement.dependencies.dependency.groupId' for "
+                                     + dependency.getManagementKey() + " is missing." )
+                    .setLocation( dependency.getLocation( "" ) ) );
                 continue;
             }
             if ( artifactId == null || artifactId.length() <= 0 )
             {
                 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                        .setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for "
-                                        + dependency.getManagementKey() + " is missing." )
-                        .setLocation( dependency.getLocation( "" ) ) );
+                    .setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for "
+                                     + dependency.getManagementKey() + " is missing." )
+                    .setLocation( dependency.getLocation( "" ) ) );
                 continue;
             }
             if ( version == null || version.length() <= 0 )
             {
                 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                        .setMessage( "'dependencyManagement.dependencies.dependency.version' for "
-                                        + dependency.getManagementKey() + " is missing." )
-                        .setLocation( dependency.getLocation( "" ) ) );
+                    .setMessage( "'dependencyManagement.dependencies.dependency.version' for "
+                                     + dependency.getManagementKey() + " is missing." )
+                    .setLocation( dependency.getLocation( "" ) ) );
                 continue;
             }
 
@@ -1074,67 +1131,85 @@ public class DefaultModelBuilder
                 continue;
             }
 
-            DependencyManagement importMngt =
-                getCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT );
+            DependencyManagement importMngt = getCache( request.getModelCache(), groupId, artifactId, version,
+                                                        ModelCacheTag.IMPORT );
 
             if ( importMngt == null )
             {
-                if ( modelResolver == null )
+                if ( workspaceResolver == null && modelResolver == null )
                 {
                     throw new IllegalArgumentException( "no model resolver provided, cannot resolve import POM "
                         + ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
                         + ModelProblemUtils.toSourceHint( model ) );
                 }
 
-                ModelSource importSource;
-                try
+                Model importModel = null;
+                if ( workspaceResolver != null )
                 {
-                    importSource = modelResolver.resolveModel( groupId, artifactId, version );
+                    try
+                    {
+                        importModel = workspaceResolver.resolveEffectiveModel( groupId, artifactId, version );
+                    }
+                    catch ( UnresolvableModelException e )
+                    {
+                        problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
+                            .setMessage( e.getMessage().toString() ).setException( e ) );
+                        continue;
+                    }
                 }
-                catch ( UnresolvableModelException e )
+
+                // no workspace resolver or workspace resolver returned null (i.e. model not in workspace)
+                if ( importModel == null )
                 {
-                    StringBuilder buffer = new StringBuilder( 256 );
-                    buffer.append( "Non-resolvable import POM" );
-                    if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
+                    final ModelSource importSource;
+                    try
                     {
-                        buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
+                        importSource = modelResolver.resolveModel( groupId, artifactId, version );
                     }
-                    buffer.append( ": " ).append( e.getMessage() );
+                    catch ( UnresolvableModelException e )
+                    {
+                        StringBuilder buffer = new StringBuilder( 256 );
+                        buffer.append( "Non-resolvable import POM" );
+                        if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
+                        {
+                            buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
+                        }
+                        buffer.append( ": " ).append( e.getMessage() );
 
-                    problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
-                            .setMessage( buffer.toString() )
-                            .setLocation( dependency.getLocation( "" ) )
+                        problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
+                            .setMessage( buffer.toString() ).setLocation( dependency.getLocation( "" ) )
                             .setException( e ) );
-                    continue;
-                }
+                        continue;
+                    }
 
-                if ( importRequest == null )
-                {
-                    importRequest = new DefaultModelBuildingRequest();
-                    importRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
-                    importRequest.setModelCache( request.getModelCache() );
-                    importRequest.setSystemProperties( request.getSystemProperties() );
-                    importRequest.setUserProperties( request.getUserProperties() );
-                    importRequest.setLocationTracking( request.isLocationTracking() );
-                }
+                    if ( importRequest == null )
+                    {
+                        importRequest = new DefaultModelBuildingRequest();
+                        importRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
+                        importRequest.setModelCache( request.getModelCache() );
+                        importRequest.setSystemProperties( request.getSystemProperties() );
+                        importRequest.setUserProperties( request.getUserProperties() );
+                        importRequest.setLocationTracking( request.isLocationTracking() );
+                    }
 
-                importRequest.setModelSource( importSource );
-                importRequest.setModelResolver( modelResolver.newCopy() );
+                    importRequest.setModelSource( importSource );
+                    importRequest.setModelResolver( modelResolver.newCopy() );
 
-                ModelBuildingResult importResult;
-                try
-                {
-                    importResult = build( importRequest );
-                }
-                catch ( ModelBuildingException e )
-                {
-                    problems.addAll( e.getProblems() );
-                    continue;
-                }
+                    final ModelBuildingResult importResult;
+                    try
+                    {
+                        importResult = build( importRequest );
+                    }
+                    catch ( ModelBuildingException e )
+                    {
+                        problems.addAll( e.getProblems() );
+                        continue;
+                    }
 
-                problems.addAll( importResult.getProblems() );
+                    problems.addAll( importResult.getProblems() );
 
-                Model importModel = importResult.getEffectiveModel();
+                    importModel = importResult.getEffectiveModel();
+                }
 
                 importMngt = importModel.getDependencyManagement();
 

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
index bd4211a..8b4a01b 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
@@ -25,8 +25,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.resolution.ModelResolver;
+import org.apache.maven.model.resolution.WorkspaceModelResolver;
 
 /**
  * Collects settings that control building of effective models.
@@ -37,6 +39,8 @@ public class DefaultModelBuildingRequest
     implements ModelBuildingRequest
 {
 
+    private Model rawModel;
+
     private File pomFile;
 
     private ModelSource modelSource;
@@ -67,6 +71,8 @@ public class DefaultModelBuildingRequest
 
     private ModelCache modelCache;
 
+    private WorkspaceModelResolver workspaceResolver;
+
     /**
      * Creates an empty request.
      */
@@ -373,4 +379,30 @@ public class DefaultModelBuildingRequest
         return this;
     }
 
+    @Override
+    public Model getRawModel()
+    {
+        return rawModel;
+    }
+
+    @Override
+    public ModelBuildingRequest setRawModel( Model rawModel )
+    {
+        this.rawModel = rawModel;
+        return this;
+    }
+
+    @Override
+    public WorkspaceModelResolver getWorkspaceModelResolver()
+    {
+        return workspaceResolver;
+    }
+
+    @Override
+    public ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver )
+    {
+        this.workspaceResolver = workspaceResolver;
+        return this;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
index 7074689..c5c2cbf 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
@@ -24,8 +24,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.resolution.ModelResolver;
+import org.apache.maven.model.resolution.WorkspaceModelResolver;
 
 /**
  * A model building request that delegates all methods invocations to another request, meant for easy transformations by
@@ -254,4 +256,30 @@ class FilterModelBuildingRequest
         return this;
     }
 
-}
+    @Override
+    public Model getRawModel()
+    {
+        return request.getRawModel();
+    }
+
+    @Override
+    public ModelBuildingRequest setRawModel( Model rawModel )
+    {
+        request.setRawModel( rawModel );
+        return this;
+    }
+
+    @Override
+    public WorkspaceModelResolver getWorkspaceModelResolver()
+    {
+        return request.getWorkspaceModelResolver();
+    }
+
+    @Override
+    public ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver )
+    {
+        request.setWorkspaceModelResolver( workspaceResolver );
+        return this;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java
index c6c75f9..2a49a21 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java
@@ -19,6 +19,10 @@ package org.apache.maven.model.building;
  * under the License.
  */
 
+import java.io.File;
+
+import org.apache.maven.model.Model;
+
 /**
  * Builds the effective model from a POM.
  *
@@ -51,4 +55,13 @@ public interface ModelBuilder
     ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingResult result )
         throws ModelBuildingException;
 
+    /**
+     * Performs only the part of {@link ModelBuilder#build(ModelBuildingRequest)} that loads the raw model
+     *
+     * @param request
+     * @return
+     * @throws ModelBuildingException
+     */
+    Result<? extends Model> buildRawModel( File pomFile, int validationLevel, boolean locationTracking );
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java
index 2a3a25a..c10274d 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java
@@ -24,8 +24,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.resolution.ModelResolver;
+import org.apache.maven.model.resolution.WorkspaceModelResolver;
 
 /**
  * Collects settings that control the building of effective models.
@@ -63,6 +65,20 @@ public interface ModelBuildingRequest
     int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0;
 
     /**
+     * Gets the raw model to build. If not set, model source will be used to load raw model.
+     * 
+     * @return The raw model to build or {@code null} if not set.
+     */
+    Model getRawModel();
+
+    /**
+     * Set raw model.
+     *
+     * @param model
+     */
+    ModelBuildingRequest setRawModel( Model rawModel );
+
+    /**
      * Gets the source of the POM to process.
      *
      * @return The source of the POM or {@code null} if not set.
@@ -315,4 +331,8 @@ public interface ModelBuildingRequest
      */
     ModelBuildingRequest setModelCache( ModelCache modelCache );
 
-}
+    WorkspaceModelResolver getWorkspaceModelResolver();
+
+    ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver );
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
new file mode 100644
index 0000000..a962897
--- /dev/null
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
@@ -0,0 +1,255 @@
+package org.apache.maven.model.building;
+
+/*
+ * 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 static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.any;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.transform;
+import static java.util.Collections.singleton;
+import static java.util.EnumSet.of;
+import static org.apache.maven.model.building.ModelProblem.Severity.ERROR;
+import static org.apache.maven.model.building.ModelProblem.Severity.FATAL;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.apache.maven.model.building.ModelProblem.Severity;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * There are various forms of results that are represented by this class:
+ * <ol>
+ * <li>success - in which case only the model field is set
+ * <li>success with warnings - model field + non-error model problems
+ * <li>error - no model, but diagnostics
+ * <li>error - (partial) model and diagnostics
+ * </ol>
+ * Could encode these variants as subclasses, but kept in one for now
+ * 
+ * @author bbusjaeger
+ * @param <T>
+ */
+public class Result<T>
+{
+
+    /**
+     * Success without warnings
+     * 
+     * @param model
+     * @return
+     */
+    public static <T> Result<T> success( T model )
+    {
+        return success( model, Collections.<ModelProblem>emptyList() );
+    }
+
+    /**
+     * Success with warnings
+     * 
+     * @param model
+     * @param problems
+     * @return
+     */
+    public static <T> Result<T> success( T model, Iterable<? extends ModelProblem> problems )
+    {
+        assert !hasErrors( problems );
+        return new Result<T>( false, model, problems );
+    }
+
+    /**
+     * Success with warnings
+     * 
+     * @param model
+     * @param results
+     * @return
+     */
+    public static <T> Result<T> success( T model, Result<?>... results )
+    {
+        return success( model, Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) );
+    }
+
+    /**
+     * Error with problems describing the cause
+     *
+     * @param problems
+     * @return
+     */
+    public static <T> Result<T> error( Iterable<? extends ModelProblem> problems )
+    {
+        return error( null, problems );
+    }
+
+    public static <T> Result<T> error( T model )
+    {
+        return error( model, Collections.<ModelProblem>emptyList() );
+    }
+
+    public static <T> Result<T> error( Result<?> result )
+    {
+        return error( result.getProblems() );
+    }
+
+    public static <T> Result<T> error( Result<?>... results )
+    {
+        return error( Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) );
+    }
+
+    /**
+     * Error with partial result and problems describing the cause
+     *
+     * @param model
+     * @param problems
+     * @return
+     */
+    public static <T> Result<T> error( T model, Iterable<? extends ModelProblem> problems )
+    {
+        return new Result<T>( true, model, problems );
+    }
+
+    /**
+     * New result - determine whether error or success by checking problems for errors
+     * 
+     * @param model
+     * @param problems
+     * @return
+     */
+    public static <T> Result<T> newResult( T model, Iterable<? extends ModelProblem> problems )
+    {
+        return new Result<T>( hasErrors( problems ), model, problems );
+    }
+
+    /**
+     * New result consisting of given result and new problem. Convenience for newResult(result.get(),
+     * concat(result.getProblems(),problems)).
+     * 
+     * @param result
+     * @param problem
+     * @return
+     */
+    public static <T> Result<T> addProblem( Result<T> result, ModelProblem problem )
+    {
+        return addProblems( result, singleton( problem ) );
+    }
+
+    /**
+     * New result that includes the given
+     *
+     * @param result
+     * @param problems
+     * @return
+     */
+    public static <T> Result<T> addProblems( Result<T> result, Iterable<? extends ModelProblem> problems )
+    {
+        return new Result<T>( result.hasErrors() || hasErrors( problems ), result.get(), concat( result.getProblems(),
+                                                                                                 problems ) );
+    }
+
+    public static <T> Result<T> addProblems( Result<T> result, Result<?>... results )
+    {
+        return addProblems( result, Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) );
+    }
+
+    /**
+     * Turns the given results into a single result by combining problems and models into single collection.
+     * 
+     * @param results
+     * @return
+     */
+    public static <T> Result<Iterable<T>> newResultSet( Iterable<? extends Result<? extends T>> results )
+    {
+        final boolean hasErrors = any( transform( results, new Function<Result<?>, Boolean>()
+        {
+            @Override
+            public Boolean apply( Result<?> input )
+            {
+                return input.hasErrors();
+            }
+        } ), Predicates.equalTo( true ) );
+        final Iterable<T> models = transform( results, new Function<Result<? extends T>, T>()
+        {
+            @Override
+            public T apply( Result<? extends T> input )
+            {
+                return input.get();
+            }
+        } );
+        final Iterable<ModelProblem> problems = concat( transform( results, GET_PROBLEMS ) );
+        return new Result<Iterable<T>>( hasErrors, models, problems );
+    }
+
+    // helper to determine if problems contain error
+    private static boolean hasErrors( Iterable<? extends ModelProblem> problems )
+    {
+        return any( transform( problems, new Function<ModelProblem, Severity>()
+        {
+            @Override
+            public Severity apply( ModelProblem input )
+            {
+                return input.getSeverity();
+            }
+        } ), in( of( ERROR, FATAL ) ) );
+    }
+
+    /**
+     * Class definition
+     */
+
+    private final boolean errors;
+
+    private final T value;
+
+    private final Iterable<? extends ModelProblem> problems;
+
+    private Result( boolean errors, T model, Iterable<? extends ModelProblem> problems )
+    {
+        this.errors = errors;
+        this.value = model;
+        this.problems = problems;
+    }
+
+    public Iterable<? extends ModelProblem> getProblems()
+    {
+        return problems;
+    }
+
+    public T get()
+    {
+        return value;
+    }
+
+    public boolean hasErrors()
+    {
+        return errors;
+    }
+
+    private static final Function<Result<?>, Iterable<? extends ModelProblem>> GET_PROBLEMS =
+        new Function<Result<?>, Iterable<? extends ModelProblem>>()
+        {
+            @Override
+            public Iterable<? extends ModelProblem> apply( Result<?> input )
+            {
+                return input.getProblems();
+            }
+        };
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java
index 733a276..bdb623a 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java
@@ -78,6 +78,22 @@ public class UnresolvableModelException
     }
 
     /**
+     * Creates a new exception with specified cause
+     *
+     * @param cause
+     * @param groupId
+     * @param artifactId
+     * @param version
+     */
+    public UnresolvableModelException( Throwable cause, String groupId, String artifactId, String version )
+    {
+        super( cause );
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+    }
+
+    /**
      * Gets the group id of the unresolvable model.
      *
      * @return The group id of the unresolvable model, can be empty but never {@code null}.

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java
new file mode 100644
index 0000000..d12edea
--- /dev/null
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java
@@ -0,0 +1,33 @@
+package org.apache.maven.model.resolution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.Model;
+
+public interface WorkspaceModelResolver
+{
+
+    Model resolveRawModel( String groupId, String artifactId, String versionConstraint )
+        throws UnresolvableModelException;
+
+    Model resolveEffectiveModel( String groupId, String artifactId, String versionConstraint )
+        throws UnresolvableModelException;
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/be3fb200/maven-model/src/main/mdo/maven.mdo
----------------------------------------------------------------------
diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo
index 43bdb7e..2821ea6 100644
--- a/maven-model/src/main/mdo/maven.mdo
+++ b/maven-model/src/main/mdo/maven.mdo
@@ -1466,12 +1466,18 @@
           <version>4.0.0+</version>
           <code>
             <![CDATA[
+    private String managementKey;
+
     /**
      * @return the management key as <code>groupId:artifactId:type</code>
      */
     public String getManagementKey()
     {
-        return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" );
+        if ( managementKey == null )
+        {
+            managementKey = groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" );
+        }
+        return managementKey;
     }
             ]]>
           </code>


Re: [1/3] maven git commit: MNG-5774 Provide an extension point for alternate CLI configuration source

Posted by Robert Scholte <rf...@apache.org>.
Op Sun, 01 Mar 2015 22:34:39 +0100 schreef <jv...@apache.org>:

> @@ -132,11 +130,6 @@ public class MavenCli
>      @SuppressWarnings( "checkstyle:constantname" )
>      public static final File userMavenConfigurationHome = new File(  
> userHome, ".m2" );
> -    public static final File DEFAULT_USER_SETTINGS_FILE = new File(  
> userMavenConfigurationHome, "settings.xml" );
> -
> -    public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
> -        new File( System.getProperty( "maven.home", System.getProperty(  
> "user.dir", "" ) ), "conf/settings.xml" );
> -
>      public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File(  
> userMavenConfigurationHome, "toolchains.xml" );
>     public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =

I'm pretty sure there are plugins which depend on these fields. Just  
removing them will make the plugins incompatible with the next releases of  
Maven. Why not mark them as deprecates and set them to  
SettingsXmlConfigurationProcessor.DEFAULT_X_SETTINGS_FILE

thanks,
Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org