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
{
projects = collectProjects( request.getFiles(), request.getLocalRepository() );
projects = collectProjects( request.getFiles(), request.getLocalRepository(), request.isRecursive() );
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
{
List projects = new ArrayList( files.size() );
@ -166,7 +166,7 @@ public class DefaultMaven
MavenProject project = getProject( file, localRepository );
if ( project.getModules() != null && !project.getModules().isEmpty() )
if ( project.getModules() != null && !project.getModules().isEmpty() && recursive )
{
project.setPackaging( "pom" );
@ -178,7 +178,7 @@ public class DefaultMaven
}
List moduleFiles = FileUtils.getFiles( project.getFile().getParentFile(), includes, null );
List collectedProjects = collectProjects( moduleFiles, localRepository );
List collectedProjects = collectProjects( moduleFiles, localRepository, recursive );
projects.addAll( collectedProjects );
project.setCollectedProjects( collectedProjects );
}

View File

@ -136,8 +136,8 @@ public class MavenCli
UserModel userModel = userModelBuilder.buildUserModel();
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder
.lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup(
ArtifactRepositoryFactory.ROLE );
ArtifactRepository localRepository = getLocalRepository( userModel, artifactRepositoryFactory );
@ -162,6 +162,11 @@ public class MavenCli
}
request = new DefaultMavenExecutionRequest( localRepository, userModel, eventDispatcher,
commandLine.getArgList(), files, userDir.getPath() );
if ( commandLine.hasOption( CLIManager.NON_RECURSIVE ) )
{
request.setRecursive( false );
}
}
LoggerManager manager = (LoggerManager) embedder.lookup( LoggerManager.ROLE );
@ -271,6 +276,8 @@ public class MavenCli
private Options options = null;
public static final char NON_RECURSIVE = 'N';
public CLIManager()
{
options = new Options();
@ -292,6 +299,8 @@ public class MavenCli
DEBUG ) );
options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
"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 )

View File

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

View File

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