This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 9b407d57dc7cc596ddb4cc2b48613f3531d3aa55
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Fri Oct 18 09:44:40 2024 +0200

    [MNG-8327] Failure when building the consumer POM
---
 .../main/java/org/apache/maven/project/DefaultProjectBuilder.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java 
b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index 954d3faf6d..9de384e9e6 100644
--- 
a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ 
b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -323,7 +323,12 @@ public class DefaultProjectBuilder implements 
ProjectBuilder {
                     RepositoryUtils.overlay(request.getLocalRepository(), 
request.getRepositorySession(), repoSystem);
             InternalSession iSession = InternalSession.from(session);
             this.modelBuilderSession = modelBuilder.newSession();
-            
iSession.getData().set(SessionData.key(ModelBuilder.ModelBuilderSession.class), 
modelBuilderSession);
+            // Save the ModelBuilderSession for later retrieval by the 
DefaultConsumerPomBuilder.
+            // Use replace(key, null, value) to make sure the *main* session, 
i.e. the one used
+            // to load the projects, is stored. This is to avoid the session 
being overwritten
+            // if a plugin uses the ProjectBuilder.
+            iSession.getData()
+                    
.replace(SessionData.key(ModelBuilder.ModelBuilderSession.class), null, 
modelBuilderSession);
         }
 
         @Override

Reply via email to