PR: MNG-208

flag project that was the root of execution

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291236 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-24 02:18:54 +00:00
parent bb95d2c1cc
commit 3e264f80ba
4 changed files with 39 additions and 15 deletions

View File

@ -104,13 +104,13 @@ public class DefaultMaven
if ( request.getSettings().isOffline() ) if ( request.getSettings().isOffline() )
{ {
getLogger().info( "\n\nNOTE: Maven is running in offline mode.\n\n" ); getLogger().info( "\n\nNOTE: Maven is running in offline mode.\n\n" );
WagonManager wagonManager = null; WagonManager wagonManager = null;
try try
{ {
wagonManager = (WagonManager) container.lookup( WagonManager.ROLE ); wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
wagonManager.setOnline( false ); wagonManager.setOnline( false );
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
@ -160,7 +160,7 @@ public class DefaultMaven
List files = getProjectFiles( request ); List files = getProjectFiles( request );
List projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(), List projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
request.getSettings(), globalProfileManager ); request.getSettings(), globalProfileManager, !request.isReactorActive() );
// the reasoning here is that the list is still unsorted according to dependency, so the first project // the reasoning here is that the list is still unsorted according to dependency, so the first project
// SHOULD BE the top-level, or the one we want to start with if we're doing an aggregated build. // SHOULD BE the top-level, or the one we want to start with if we're doing an aggregated build.
@ -264,7 +264,7 @@ public class DefaultMaven
catch ( LifecycleExecutionException e ) catch ( LifecycleExecutionException e )
{ {
logFatal( e ); logFatal( e );
throw new ReactorException( "Error executing project within the reactor", e ); throw new ReactorException( "Error executing project within the reactor", e );
} }
@ -351,7 +351,7 @@ public class DefaultMaven
} }
private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings, private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
ProfileManager globalProfileManager ) ProfileManager globalProfileManager, boolean isRoot )
throws ProjectBuildingException, ReactorException, IOException, ArtifactResolutionException, throws ProjectBuildingException, ReactorException, IOException, ArtifactResolutionException,
ProfileActivationException ProfileActivationException
{ {
@ -371,6 +371,11 @@ public class DefaultMaven
MavenProject project = getProject( file, localRepository, settings, globalProfileManager ); MavenProject project = getProject( file, localRepository, settings, globalProfileManager );
if ( isRoot )
{
project.setExecutionRoot( true );
}
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null ) if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
{ {
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
@ -409,7 +414,7 @@ public class DefaultMaven
} }
List collectedProjects = collectProjects( moduleFiles, localRepository, recursive, settings, List collectedProjects = collectProjects( moduleFiles, localRepository, recursive, settings,
globalProfileManager ); globalProfileManager, false );
projects.addAll( collectedProjects ); projects.addAll( collectedProjects );
project.setCollectedProjects( collectedProjects ); project.setCollectedProjects( collectedProjects );
} }
@ -530,7 +535,7 @@ public class DefaultMaven
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Reporting / Logging // Reporting / Logging
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
protected void logFatal( Throwable error ) protected void logFatal( Throwable error )
{ {
line(); line();
@ -540,7 +545,7 @@ public class DefaultMaven
line(); line();
diagnoseError( error ); diagnoseError( error );
line(); line();
} }
@ -553,7 +558,7 @@ public class DefaultMaven
line(); line();
diagnoseError( r.getException() ); diagnoseError( r.getException() );
line(); line();
stats( r.getStart(), r.getFinish() ); stats( r.getStart(), r.getFinish() );

View File

@ -346,7 +346,7 @@ public class DefaultMavenProjectBuilder
try try
{ {
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository ); artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
File file = projectArtifact.getFile(); File file = projectArtifact.getFile();
model = readModel( file ); model = readModel( file );
@ -1167,6 +1167,8 @@ public class DefaultMavenProjectBuilder
project = processProjectLogic( "<Super-POM>", project, remoteRepositories, null, null ); project = processProjectLogic( "<Super-POM>", project, remoteRepositories, null, null );
project.setExecutionRoot( true );
return project; return project;
} }
catch ( ModelInterpolationException e ) catch ( ModelInterpolationException e )

View File

@ -134,6 +134,8 @@ public class MavenProject
private Build buildOverlay; private Build buildOverlay;
private boolean executionRoot;
public MavenProject( Model model ) public MavenProject( Model model )
{ {
this.model = model; this.model = model;
@ -181,6 +183,8 @@ public class MavenProject
this.originalModel = ModelUtils.cloneModel( project.originalModel ); this.originalModel = ModelUtils.cloneModel( project.originalModel );
} }
this.executionRoot = project.executionRoot;
// TODO: need to clone this too? // TODO: need to clone this too?
this.artifact = project.artifact; this.artifact = project.artifact;
} }
@ -1449,4 +1453,14 @@ public class MavenProject
{ {
return projectReferences; return projectReferences;
} }
public boolean isExecutionRoot()
{
return executionRoot;
}
public void setExecutionRoot( boolean executionRoot )
{
this.executionRoot = executionRoot;
}
} }

View File

@ -169,11 +169,14 @@ public class ProjectSorter
{ {
if ( topLevelProject == null ) if ( topLevelProject == null )
{ {
List projectsByFile = new ArrayList( sortedProjects ); for ( Iterator i = sortedProjects.iterator(); i.hasNext() && topLevelProject == null; )
{
Collections.sort( projectsByFile, new ByProjectFileComparator() ); MavenProject project = (MavenProject) i.next();
if ( project.isExecutionRoot() )
topLevelProject = (MavenProject) projectsByFile.get( 0 ); {
topLevelProject = project;
}
}
} }
return topLevelProject; return topLevelProject;