mirror of https://github.com/apache/maven.git
[MNG-5009] StackOverflowError in DefaultProjectBuilder.build when <module> points at current aggregator POM
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1070083 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec1c5f30a6
commit
304450abdd
|
@ -303,7 +303,8 @@ public class DefaultProjectBuilder
|
|||
ReactorModelCache modelCache = new ReactorModelCache();
|
||||
|
||||
boolean noErrors =
|
||||
build( results, interimResults, pomFiles, true, recursive, config, modelPool, modelCache );
|
||||
build( results, interimResults, pomFiles, new LinkedHashSet<File>(), true, recursive, config, modelPool,
|
||||
modelCache );
|
||||
|
||||
populateReactorModelPool( modelPool, interimResults );
|
||||
|
||||
|
@ -329,13 +330,34 @@ public class DefaultProjectBuilder
|
|||
}
|
||||
|
||||
private boolean build( List<ProjectBuildingResult> results, List<InterimResult> interimResults,
|
||||
List<File> pomFiles, boolean isRoot, boolean recursive, ProjectBuildingRequest config,
|
||||
ReactorModelPool reactorModelPool, ReactorModelCache modelCache )
|
||||
List<File> pomFiles, Set<File> aggregatorFiles, boolean isRoot, boolean recursive,
|
||||
ProjectBuildingRequest config, ReactorModelPool reactorModelPool,
|
||||
ReactorModelCache modelCache )
|
||||
{
|
||||
boolean noErrors = true;
|
||||
|
||||
for ( File pomFile : pomFiles )
|
||||
{
|
||||
aggregatorFiles.add( pomFile );
|
||||
|
||||
if ( !build( results, interimResults, pomFile, aggregatorFiles, isRoot, recursive, config,
|
||||
reactorModelPool, modelCache ) )
|
||||
{
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
aggregatorFiles.remove( pomFile );
|
||||
}
|
||||
|
||||
return noErrors;
|
||||
}
|
||||
|
||||
private boolean build( List<ProjectBuildingResult> results, List<InterimResult> interimResults, File pomFile,
|
||||
Set<File> aggregatorFiles, boolean isRoot, boolean recursive, ProjectBuildingRequest config,
|
||||
ReactorModelPool reactorModelPool, ReactorModelCache modelCache )
|
||||
{
|
||||
boolean noErrors = true;
|
||||
|
||||
ModelBuildingRequest request = getModelBuildingRequest( config, reactorModelPool );
|
||||
|
||||
MavenProject project = new MavenProject( repositorySystem, this, config, logger );
|
||||
|
@ -409,12 +431,32 @@ public class DefaultProjectBuilder
|
|||
moduleFile = new File( moduleFile.toURI().normalize() );
|
||||
}
|
||||
|
||||
if ( aggregatorFiles.contains( moduleFile ) )
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder( 256 );
|
||||
for ( File aggregatorFile : aggregatorFiles )
|
||||
{
|
||||
buffer.append( aggregatorFile ).append( " -> " );
|
||||
}
|
||||
buffer.append( moduleFile );
|
||||
|
||||
ModelProblem problem =
|
||||
new DefaultModelProblem( "Child module " + moduleFile + " of " + pomFile
|
||||
+ " forms aggregation cycle " + buffer, ModelProblem.Severity.ERROR, model, -1, -1,
|
||||
null );
|
||||
result.getProblems().add( problem );
|
||||
|
||||
noErrors = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
moduleFiles.add( moduleFile );
|
||||
}
|
||||
|
||||
interimResult.modules = new ArrayList<InterimResult>();
|
||||
|
||||
if ( !build( results, interimResult.modules, moduleFiles, false, recursive, config,
|
||||
if ( !build( results, interimResult.modules, moduleFiles, aggregatorFiles, false, recursive, config,
|
||||
reactorModelPool, modelCache ) )
|
||||
{
|
||||
noErrors = false;
|
||||
|
@ -427,7 +469,6 @@ public class DefaultProjectBuilder
|
|||
|
||||
noErrors = false;
|
||||
}
|
||||
}
|
||||
|
||||
return noErrors;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue