mirror of https://github.com/apache/maven.git
o Improved handling of circular parents
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@885106 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f918716071
commit
411fd3c42b
|
@ -117,7 +117,7 @@ public class DefaultModelBuilder
|
|||
return build( request, new LinkedHashSet<String>() );
|
||||
}
|
||||
|
||||
private ModelBuildingResult build( ModelBuildingRequest request, Collection<String> imports )
|
||||
private ModelBuildingResult build( ModelBuildingRequest request, Collection<String> importIds )
|
||||
throws ModelBuildingException
|
||||
{
|
||||
DefaultModelBuildingResult result = new DefaultModelBuildingResult();
|
||||
|
@ -137,6 +137,9 @@ public class DefaultModelBuilder
|
|||
ModelData resultData = new ModelData( inputModel );
|
||||
ModelData superData = new ModelData( getSuperModel() );
|
||||
|
||||
Collection<String> parentIds = new LinkedHashSet<String>();
|
||||
parentIds.add( ModelProblemUtils.toId( inputModel ) );
|
||||
|
||||
List<ModelData> lineage = new ArrayList<ModelData>();
|
||||
|
||||
for ( ModelData currentData = resultData; currentData != null; )
|
||||
|
@ -182,6 +185,18 @@ public class DefaultModelBuilder
|
|||
{
|
||||
currentData = superData;
|
||||
}
|
||||
else if ( !parentIds.add( currentData.getId() ) )
|
||||
{
|
||||
String message = "The parents form a cycle: ";
|
||||
for ( String modelId : parentIds )
|
||||
{
|
||||
message += modelId + " -> ";
|
||||
}
|
||||
message += currentData.getId();
|
||||
|
||||
problems.add( ModelProblem.Severity.FATAL, message, null );
|
||||
throw new ModelBuildingException( problems.getRootModelId(), problems.getProblems() );
|
||||
}
|
||||
}
|
||||
|
||||
assembleInheritance( lineage, request, problems );
|
||||
|
@ -588,7 +603,7 @@ public class DefaultModelBuilder
|
|||
}
|
||||
|
||||
private void importDependencyManagement( Model model, ModelBuildingRequest request,
|
||||
DefaultModelProblemCollector problems, Collection<String> imports )
|
||||
DefaultModelProblemCollector problems, Collection<String> importIds )
|
||||
{
|
||||
DependencyManagement depMngt = model.getDependencyManagement();
|
||||
|
||||
|
@ -599,7 +614,7 @@ public class DefaultModelBuilder
|
|||
|
||||
String importing = model.getGroupId() + ':' + model.getArtifactId() + ':' + model.getVersion();
|
||||
|
||||
imports.add( importing );
|
||||
importIds.add( importing );
|
||||
|
||||
ModelResolver modelResolver = request.getModelResolver();
|
||||
|
||||
|
@ -624,10 +639,10 @@ public class DefaultModelBuilder
|
|||
|
||||
String imported = groupId + ':' + artifactId + ':' + version;
|
||||
|
||||
if ( imports.contains( imported ) )
|
||||
if ( importIds.contains( imported ) )
|
||||
{
|
||||
String message = "The dependencies of type=pom and with scope=import form a cycle: ";
|
||||
for ( String modelId : imports )
|
||||
for ( String modelId : importIds )
|
||||
{
|
||||
message += modelId + " -> ";
|
||||
}
|
||||
|
@ -673,7 +688,7 @@ public class DefaultModelBuilder
|
|||
ModelBuildingResult importResult;
|
||||
try
|
||||
{
|
||||
importResult = build( importRequest, imports );
|
||||
importResult = build( importRequest, importIds );
|
||||
}
|
||||
catch ( ModelBuildingException e )
|
||||
{
|
||||
|
@ -703,7 +718,7 @@ public class DefaultModelBuilder
|
|||
importMngts.add( importMngt );
|
||||
}
|
||||
|
||||
imports.remove( importing );
|
||||
importIds.remove( importing );
|
||||
|
||||
dependencyManagementImporter.importManagement( model, importMngts, request, problems );
|
||||
}
|
||||
|
|
|
@ -86,6 +86,11 @@ class DefaultModelProblemCollector
|
|||
{
|
||||
this.sourceModel = source;
|
||||
this.source = null;
|
||||
|
||||
if ( rootModel == null )
|
||||
{
|
||||
rootModel = source;
|
||||
}
|
||||
}
|
||||
|
||||
private String getSource()
|
||||
|
|
Loading…
Reference in New Issue