correct no project handling (eg archetype:create)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@226540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-30 16:04:02 +00:00
parent 5e75912ed1
commit 47744229e8
1 changed files with 30 additions and 27 deletions

View File

@ -125,36 +125,38 @@ public MavenExecutionResponse execute( MavenExecutionRequest request )
}
EventDispatcher dispatcher = request.getEventDispatcher();
String event = MavenEvents.REACTOR_EXECUTION;
dispatcher.dispatchStart( event, request.getBaseDirectory() );
List projects;
MavenProject topLevelProject;
try
{
List files = getProjectFiles( request );
projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
request.getSettings() );
// 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.
// TODO: !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness.
topLevelProject = (MavenProject) projects.get( 0 );
projects = ProjectSorter.getSortedProjects(projects);
if ( projects.isEmpty() )
if ( !projects.isEmpty() )
{
// TODO: !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness.
topLevelProject = (MavenProject) projects.get( 0 );
projects = ProjectSorter.getSortedProjects( projects );
}
else
{
List externalProfiles = getActiveExternalProfiles( null, request.getSettings() );
projects.add(
projectBuilder.buildStandaloneSuperProject( request.getLocalRepository(), externalProfiles ) );
topLevelProject = projectBuilder.buildStandaloneSuperProject( request.getLocalRepository(),
externalProfiles );
projects.add( topLevelProject );
}
}
catch ( IOException e )
@ -201,11 +203,11 @@ public MavenExecutionResponse execute( MavenExecutionRequest request )
try
{
MavenSession session = createSession( request, projects );
try
{
MavenExecutionResponse response = lifecycleExecutor.execute( session, topLevelProject, dispatcher );
// TODO: is this perhaps more appropriate in the CLI?
if ( response.isExecutionFailure() )
{
@ -219,7 +221,7 @@ public MavenExecutionResponse execute( MavenExecutionRequest request )
if ( exception.getCause() == null )
{
MojoExecutionException e = (MojoExecutionException) exception;
logFailure( response, e, e.getLongMessage() );
}
else
@ -240,7 +242,7 @@ else if ( exception instanceof ArtifactResolutionException )
// one example)
logError( response );
}
return response;
}
else
@ -279,7 +281,7 @@ private List collectProjects( List files, ArtifactRepository localRepository, bo
{
getLogger().info( "NOTE: Using release-pom: " + file + " in reactor build." );
}
MavenProject project = getProject( file, localRepository, settings );
if ( project.getPrerequesites() != null && project.getPrerequesites().getMaven() != null )
@ -402,7 +404,8 @@ private List getActiveExternalProfiles( File pom, Settings settings )
protected MavenSession createSession( MavenExecutionRequest request, List projects )
{
return new MavenSession( container, request.getSettings(), request.getLocalRepository(),
request.getEventDispatcher(), projects, request.getGoals(), request.getBaseDirectory() );
request.getEventDispatcher(), projects, request.getGoals(),
request.getBaseDirectory() );
}
/**
@ -622,12 +625,12 @@ else if ( min == 0 )
}
return msg;
}
private List getProjectFiles( MavenExecutionRequest request )
throws IOException
{
List files = Collections.EMPTY_LIST;
if ( request.isReactorActive() )
{
// TODO: should we now include the pom.xml in the current directory?
@ -636,9 +639,9 @@ private List getProjectFiles( MavenExecutionRequest request )
String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4 + ",**/" + RELEASE_POMv4 );
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 + "," + RELEASE_POMv4 );
files = FileUtils.getFiles( userDir, includes, excludes );
filterOneProjectFilePerDirectory( files );
// make sure there is consistent ordering on all platforms, rather than using the filesystem ordering
@ -667,28 +670,28 @@ else if ( request.getPomFile() != null )
files = Collections.singletonList( projectFile );
}
}
return files;
}
private void filterOneProjectFilePerDirectory( List files )
{
List releaseDirs = new ArrayList();
for ( Iterator it = files.iterator(); it.hasNext(); )
{
File projectFile = (File) it.next();
if ( RELEASE_POMv4.equals( projectFile.getName() ) )
{
releaseDirs.add( projectFile.getParentFile() );
}
}
for ( Iterator it = files.iterator(); it.hasNext(); )
{
File projectFile = (File) it.next();
// remove pom.xml files where there is a sibling release-pom.xml file...
if ( !RELEASE_POMv4.equals( projectFile.getName() ) && releaseDirs.contains( projectFile.getParentFile() ) )
{