From a3cb0d140adf0102b26af801c4720cc3ae92c7ca Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sat, 26 Oct 2024 19:16:04 +0200 Subject: [PATCH] [MNG-8340] Resolve parent according to the exact model location --- .../org/apache/maven/project/DefaultProjectBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 9de384e9e604..110bc1da6588 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -565,7 +565,12 @@ private static org.apache.maven.model.building.ModelProblem convert(ModelProblem @SuppressWarnings({"checkstyle:methodlength", "deprecation"}) private void initProject(MavenProject project, ModelBuilderResult result) { project.setModel(new org.apache.maven.model.Model(result.getEffectiveModel())); - project.setOriginalModel(new org.apache.maven.model.Model(result.getFileModel())); + Model originalModel = result.getFileModel(); + if (originalModel.getParent() != null && originalModel.getParent().getRelativePath() == null) { + originalModel = + originalModel.withParent(originalModel.getParent().withRelativePath("..")); + } + project.setOriginalModel(new org.apache.maven.model.Model(originalModel)); initParent(project, result);