List<DependencyManagement> importMngts = null;
for ( Iterator<Dependency> it = depMngt.getDependencies().iterator(); it.hasNext(); )
{
Dependency dependency = it.next();
if ( !"pom".equals( dependency.getType() ) || !"import".equals( dependency.getScope() ) )
{
continue;
}
it.remove();
String groupId = dependency.getGroupId();
String artifactId = dependency.getArtifactId();
String version = dependency.getVersion();
String imported = groupId + ':' + artifactId + ':' + version;
if ( importIds.contains( imported ) )
{
String message = "The dependencies of type=pom and with scope=import form a cycle: ";
for ( String modelId : importIds )
{
message += modelId + " -> ";
}
message += imported;
problems.add( Severity.ERROR, message, null, null );
continue;
}
DependencyManagement importMngt =
getCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT );
if ( importMngt == null )
{
if ( modelResolver == null )
{
throw new IllegalArgumentException( "no model resolver provided, cannot resolve import POM "
+ ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
+ ModelProblemUtils.toSourceHint( model ) );
}
ModelSource importSource;
try
{
importSource = modelResolver.resolveModel( groupId, artifactId, version );
}
catch ( UnresolvableModelException e )
{
StringBuilder buffer = new StringBuilder( 256 );
buffer.append( "Non-resolvable import POM" );
if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
{
buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
}
buffer.append( ": " ).append( e.getMessage() );
problems.add( Severity.ERROR, buffer.toString(), dependency.getLocation( "" ), e );
continue;
}
if ( importRequest == null )
{