PR: MNG-205

Add a non-recursive mode to disable processing of modules


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163572 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-16 03:48:30 +00:00
parent dda9fa50fb
commit ba992be685
4 changed files with 34 additions and 9 deletions

View File

@ -96,7 +96,7 @@ public class DefaultMaven
try try
{ {
projects = collectProjects( request.getFiles(), request.getLocalRepository() ); projects = collectProjects( request.getFiles(), request.getLocalRepository(), request.isRecursive() );
projects = projectBuilder.getSortedProjects( projects ); projects = projectBuilder.getSortedProjects( projects );
@ -155,7 +155,7 @@ public class DefaultMaven
} }
} }
private List collectProjects( List files, ArtifactRepository localRepository ) private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive )
throws ProjectBuildingException, ReactorException, IOException throws ProjectBuildingException, ReactorException, IOException
{ {
List projects = new ArrayList( files.size() ); List projects = new ArrayList( files.size() );
@ -166,7 +166,7 @@ public class DefaultMaven
MavenProject project = getProject( file, localRepository ); MavenProject project = getProject( file, localRepository );
if ( project.getModules() != null && !project.getModules().isEmpty() ) if ( project.getModules() != null && !project.getModules().isEmpty() && recursive )
{ {
project.setPackaging( "pom" ); project.setPackaging( "pom" );
@ -178,7 +178,7 @@ public class DefaultMaven
} }
List moduleFiles = FileUtils.getFiles( project.getFile().getParentFile(), includes, null ); List moduleFiles = FileUtils.getFiles( project.getFile().getParentFile(), includes, null );
List collectedProjects = collectProjects( moduleFiles, localRepository ); List collectedProjects = collectProjects( moduleFiles, localRepository, recursive );
projects.addAll( collectedProjects ); projects.addAll( collectedProjects );
project.setCollectedProjects( collectedProjects ); project.setCollectedProjects( collectedProjects );
} }

View File

@ -136,8 +136,8 @@ public class MavenCli
UserModel userModel = userModelBuilder.buildUserModel(); UserModel userModel = userModelBuilder.buildUserModel();
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup(
.lookup( ArtifactRepositoryFactory.ROLE ); ArtifactRepositoryFactory.ROLE );
ArtifactRepository localRepository = getLocalRepository( userModel, artifactRepositoryFactory ); ArtifactRepository localRepository = getLocalRepository( userModel, artifactRepositoryFactory );
@ -162,6 +162,11 @@ public class MavenCli
} }
request = new DefaultMavenExecutionRequest( localRepository, userModel, eventDispatcher, request = new DefaultMavenExecutionRequest( localRepository, userModel, eventDispatcher,
commandLine.getArgList(), files, userDir.getPath() ); commandLine.getArgList(), files, userDir.getPath() );
if ( commandLine.hasOption( CLIManager.NON_RECURSIVE ) )
{
request.setRecursive( false );
}
} }
LoggerManager manager = (LoggerManager) embedder.lookup( LoggerManager.ROLE ); LoggerManager manager = (LoggerManager) embedder.lookup( LoggerManager.ROLE );
@ -271,6 +276,8 @@ public class MavenCli
private Options options = null; private Options options = null;
public static final char NON_RECURSIVE = 'N';
public CLIManager() public CLIManager()
{ {
options = new Options(); options = new Options();
@ -292,6 +299,8 @@ public class MavenCli
DEBUG ) ); DEBUG ) );
options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription( options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
"Execute goals for project found in the reactor" ).create( REACTOR ) ); "Execute goals for project found in the reactor" ).create( REACTOR ) );
options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription(
"Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
} }
public CommandLine parse( String[] args ) public CommandLine parse( String[] args )

View File

@ -51,6 +51,8 @@ public class DefaultMavenExecutionRequest
private final String baseDirectory; private final String baseDirectory;
private boolean recursive = true;
public DefaultMavenExecutionRequest( ArtifactRepository localRepository, UserModel userModel, public DefaultMavenExecutionRequest( ArtifactRepository localRepository, UserModel userModel,
EventDispatcher eventDispatcher, List goals, List files, String baseDirectory ) EventDispatcher eventDispatcher, List goals, List files, String baseDirectory )
{ {
@ -77,6 +79,16 @@ public class DefaultMavenExecutionRequest
return baseDirectory; return baseDirectory;
} }
public boolean isRecursive()
{
return recursive;
}
public void setRecursive( boolean recursive )
{
this.recursive = false;
}
public ArtifactRepository getLocalRepository() public ArtifactRepository getLocalRepository()
{ {
return localRepository; return localRepository;

View File

@ -52,4 +52,8 @@ public interface MavenExecutionRequest
UserModel getUserModel(); UserModel getUserModel();
String getBaseDirectory(); String getBaseDirectory();
void setRecursive( boolean recursive );
boolean isRecursive();
} }