diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java index 8e077fd109b43..7beaf74042384 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java @@ -69,7 +69,7 @@ public static LocalProject load(Path path, boolean required) throws BootstrapMav return null; } try { - return new LocalProject(readModel(pom), null); + return new LocalProject(readModel(pom), null, null); } catch (UnresolvedVersionException e) { // if a property in the version couldn't be resolved, we are trying to resolve it from the workspace return loadWorkspace(pom); @@ -165,10 +165,10 @@ static Path locateCurrentProjectPom(Path path, boolean required) throws Bootstra } } - LocalProject(Model rawModel, LocalWorkspace workspace) throws BootstrapMavenException { + LocalProject(Model rawModel, LocalWorkspace workspace, Path projectDirectory) throws BootstrapMavenException { this.modelBuildingResult = null; this.rawModel = rawModel; - this.dir = rawModel.getProjectDirectory().toPath(); + this.dir = (projectDirectory != null) ? projectDirectory : rawModel.getProjectDirectory().toPath(); this.workspace = workspace; this.key = ArtifactKey.ga(ModelUtils.getGroupId(rawModel), rawModel.getArtifactId()); diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java index d3772143e0d8e..e499ae14eb7bd 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java @@ -146,9 +146,9 @@ private LocalProject loadAndCacheProject(Path pomFile) throws BootstrapMavenExce throw new BootstrapMavenException("Failed to resolve the effective model for " + pomFile, e); } } else { - project = new LocalProject(rawModel, workspace); + project = new LocalProject(rawModel, workspace, resolveProjectPath(pomFile)); } - projectCache.put(pomFile.getParent(), project); + projectCache.put(resolveProjectPath(pomFile), project); return project; } @@ -272,6 +272,13 @@ public Model resolveEffectiveModel(String groupId, String artifactId, String ver : null; } + private Path resolveProjectPath(Path pomFile) { + if (pomFile.endsWith("target/.flattened-pom.xml")) { + return pomFile.getParent().getParent().toAbsolutePath(); + } + return pomFile.getParent().toAbsolutePath(); + } + @Override public WorkspaceRepository getRepository() { return workspace.getRepository();