[MNG-5669] Fix infinitive loop in case pom.xml is being updated during the process (e.g. maven-shade-plugin writing reduced-pom with excluded dependencies)

This commit is contained in:
rfscholte 2020-03-13 09:07:19 +01:00
parent 9e92a93ab8
commit 5cdb8332f9
1 changed files with 16 additions and 11 deletions

View File

@ -539,10 +539,14 @@ public class DefaultModelBuilder
new FileModelSource( Objects.requireNonNull( pomFile, "neither pomFile nor modelSource can be null" ) );
}
Model model = getModelFromCache( modelSource, request.getModelCache() );
if ( model != null )
Model model;
if ( pomFile == null )
{
return model;
model = getModelFromCache( modelSource, request.getModelCache() );
if ( model != null )
{
return model;
}
}
problems.setSource( modelSource.getLocation() );
@ -634,7 +638,14 @@ public class DefaultModelBuilder
throw problems.newModelBuildingException();
}
model.setPomFile( pomFile );
if ( pomFile != null )
{
model.setPomFile( pomFile );
}
else if ( modelSource instanceof FileModelSource )
{
model.setPomFile( ( (FileModelSource) modelSource ).getFile() );
}
problems.setSource( model );
modelValidator.validateRawModel( model, request, problems );
@ -992,13 +1003,7 @@ public class DefaultModelBuilder
return null;
}
File pomFile = null;
if ( candidateSource instanceof FileModelSource )
{
pomFile = ( (FileModelSource) candidateSource ).getPomFile();
}
candidateModel = readModel( candidateSource, pomFile, request, problems );
candidateModel = readModel( candidateSource, null, request, problems );
}
else
{