You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/03/08 12:04:50 UTC
[maven] 01/01: [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 is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-5669
in repository https://gitbox.apache.org/repos/asf/maven.git
commit a151f10c7823cbbbe98446acad68da0ff82f2e04
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Mar 8 13:04:35 2020 +0100
[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)
---
.../maven/model/building/DefaultModelBuilder.java | 27 +++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index cc1ba71..d059569 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -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
{