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>() );
|
return build( request, new LinkedHashSet<String>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModelBuildingResult build( ModelBuildingRequest request, Collection<String> imports )
|
private ModelBuildingResult build( ModelBuildingRequest request, Collection<String> importIds )
|
||||||
throws ModelBuildingException
|
throws ModelBuildingException
|
||||||
{
|
{
|
||||||
DefaultModelBuildingResult result = new DefaultModelBuildingResult();
|
DefaultModelBuildingResult result = new DefaultModelBuildingResult();
|
||||||
|
@ -137,6 +137,9 @@ public class DefaultModelBuilder
|
||||||
ModelData resultData = new ModelData( inputModel );
|
ModelData resultData = new ModelData( inputModel );
|
||||||
ModelData superData = new ModelData( getSuperModel() );
|
ModelData superData = new ModelData( getSuperModel() );
|
||||||
|
|
||||||
|
Collection<String> parentIds = new LinkedHashSet<String>();
|
||||||
|
parentIds.add( ModelProblemUtils.toId( inputModel ) );
|
||||||
|
|
||||||
List<ModelData> lineage = new ArrayList<ModelData>();
|
List<ModelData> lineage = new ArrayList<ModelData>();
|
||||||
|
|
||||||
for ( ModelData currentData = resultData; currentData != null; )
|
for ( ModelData currentData = resultData; currentData != null; )
|
||||||
|
@ -182,6 +185,18 @@ public class DefaultModelBuilder
|
||||||
{
|
{
|
||||||
currentData = superData;
|
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 );
|
assembleInheritance( lineage, request, problems );
|
||||||
|
@ -588,7 +603,7 @@ public class DefaultModelBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importDependencyManagement( Model model, ModelBuildingRequest request,
|
private void importDependencyManagement( Model model, ModelBuildingRequest request,
|
||||||
DefaultModelProblemCollector problems, Collection<String> imports )
|
DefaultModelProblemCollector problems, Collection<String> importIds )
|
||||||
{
|
{
|
||||||
DependencyManagement depMngt = model.getDependencyManagement();
|
DependencyManagement depMngt = model.getDependencyManagement();
|
||||||
|
|
||||||
|
@ -599,7 +614,7 @@ public class DefaultModelBuilder
|
||||||
|
|
||||||
String importing = model.getGroupId() + ':' + model.getArtifactId() + ':' + model.getVersion();
|
String importing = model.getGroupId() + ':' + model.getArtifactId() + ':' + model.getVersion();
|
||||||
|
|
||||||
imports.add( importing );
|
importIds.add( importing );
|
||||||
|
|
||||||
ModelResolver modelResolver = request.getModelResolver();
|
ModelResolver modelResolver = request.getModelResolver();
|
||||||
|
|
||||||
|
@ -624,10 +639,10 @@ public class DefaultModelBuilder
|
||||||
|
|
||||||
String imported = groupId + ':' + artifactId + ':' + version;
|
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: ";
|
String message = "The dependencies of type=pom and with scope=import form a cycle: ";
|
||||||
for ( String modelId : imports )
|
for ( String modelId : importIds )
|
||||||
{
|
{
|
||||||
message += modelId + " -> ";
|
message += modelId + " -> ";
|
||||||
}
|
}
|
||||||
|
@ -673,7 +688,7 @@ public class DefaultModelBuilder
|
||||||
ModelBuildingResult importResult;
|
ModelBuildingResult importResult;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
importResult = build( importRequest, imports );
|
importResult = build( importRequest, importIds );
|
||||||
}
|
}
|
||||||
catch ( ModelBuildingException e )
|
catch ( ModelBuildingException e )
|
||||||
{
|
{
|
||||||
|
@ -703,7 +718,7 @@ public class DefaultModelBuilder
|
||||||
importMngts.add( importMngt );
|
importMngts.add( importMngt );
|
||||||
}
|
}
|
||||||
|
|
||||||
imports.remove( importing );
|
importIds.remove( importing );
|
||||||
|
|
||||||
dependencyManagementImporter.importManagement( model, importMngts, request, problems );
|
dependencyManagementImporter.importManagement( model, importMngts, request, problems );
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,11 @@ class DefaultModelProblemCollector
|
||||||
{
|
{
|
||||||
this.sourceModel = source;
|
this.sourceModel = source;
|
||||||
this.source = null;
|
this.source = null;
|
||||||
|
|
||||||
|
if ( rootModel == null )
|
||||||
|
{
|
||||||
|
rootModel = source;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSource()
|
private String getSource()
|
||||||
|
|
Loading…
Reference in New Issue