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