You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/09/20 19:33:05 UTC
(maven) branch agent/parent-pomfile created (now 9c4406982f)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch agent/parent-pomfile
in repository https://gitbox.apache.org/repos/asf/maven.git
at 9c4406982f Keep the basedir unset for a parent served from the project-local repository
This branch includes the following new commits:
new 9c4406982f Keep the basedir unset for a parent served from the project-local repository
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven) 01/01: Keep the basedir unset for a parent served from the project-local repository
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch agent/parent-pomfile
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 9c4406982f74c2ee34b36a8877f266262b6c2ce9
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun Sep 20 21:30:58 2026 +0200
Keep the basedir unset for a parent served from the project-local repository
The ReactorReader also answers for POMs it stored in .mvn/target/project-local-repo,
so a parent installed by an earlier build resolves from the WorkspaceRepository and
DefaultProjectBuilder treated it as a checkout, giving it a basedir inside the
repository. Only a POM of a project in this session is a checkout; anything else the
workspace serves is built like a repository artifact, with the file unset as on Maven 3.
Closes #13211
---
.../org/apache/maven/project/DefaultProjectBuilder.java | 16 +++++++++++++++-
1 file changed, 15 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 b6ac66cbb3..51ee3e0d01 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
@@ -439,6 +439,17 @@ ProjectBuildingResult build(boolean parent, Path pomFile, ModelSource modelSourc
}
}
+ private boolean isProjectPom(Path pomFile) {
+ List<org.apache.maven.api.Project> projects = session.getProjects();
+ if (pomFile == null || projects == null) { // no reactor yet while the session is being set up
+ return false;
+ }
+ Path path = pomFile.toAbsolutePath().normalize();
+ return projects.stream()
+ .filter(Objects::nonNull)
+ .anyMatch(p -> p.getPomPath().toAbsolutePath().normalize().equals(path));
+ }
+
ProjectBuildingResult build(
boolean parent, Artifact artifact, boolean allowStubModel, List<ArtifactRepository> repositories)
throws ProjectBuildingException {
@@ -463,7 +474,10 @@ ProjectBuildingResult build(
ArtifactResolverResult.ResultItem resItem = res.getResult(coordinates);
pomArtifact = InternalMavenSession.from(session).toArtifact(resItem.getArtifact());
- localProject = resItem.getRepository() instanceof org.apache.maven.api.WorkspaceRepository;
+ // the workspace also serves copies from the project-local repository; only a POM that belongs to
+ // a project of this session is a checkout with a basedir, the rest is treated like a repository
+ localProject = resItem.getRepository() instanceof org.apache.maven.api.WorkspaceRepository
+ && isProjectPom(pomArtifact.getPath());
} catch (ArtifactResolverException e) {
if (e.getResult().getResults().values().iterator().next().isMissing() && allowStubModel) {
return build(parent, null, createStubModelSource(artifact));