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 3489534143..115d6627e7 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 @@ -124,11 +124,23 @@ public class MavenSession public void setProjects( List projects ) { - //TODO: Current for testing classes creating the session - if ( projects.size() > 0 ) + if ( !projects.isEmpty() ) { this.currentProject = projects.get( 0 ); - this.topLevelProject = projects.get( 0 ); + this.topLevelProject = currentProject; + for ( MavenProject project : projects ) + { + if ( project.isExecutionRoot() ) + { + topLevelProject = project; + break; + } + } + } + else + { + this.currentProject = null; + this.topLevelProject = null; } this.projects = projects; } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index fafc6b224e..c6b367d3e4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -451,18 +451,16 @@ public class DefaultProjectBuilder MavenProject project = interimResult.listener.getProject(); initProject( project, result ); - projects.add( project ); - - results.add( new DefaultProjectBuildingResult( project, result.getProblems(), null ) ); - - project.setExecutionRoot( interimResult.root ); - List modules = new ArrayList(); noErrors = build( results, modules, interimResult.modules, config ) && noErrors; projects.addAll( modules ); + projects.add( project ); + project.setExecutionRoot( interimResult.root ); project.setCollectedProjects( modules ); + + results.add( new DefaultProjectBuildingResult( project, result.getProblems(), null ) ); } catch ( ModelBuildingException e ) {