From 40c3a73e282925ce5181ee53472972cb1086572a Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Sat, 11 Feb 2023 21:11:23 +0100 Subject: [PATCH] Use the effective Maven project build config when initializing sources and classes paths for dev mode --- .../io/quarkus/maven/QuarkusBootstrapProvider.java | 7 +++++-- .../resolver/maven/workspace/LocalProject.java | 2 +- .../resolver/maven/workspace/WorkspaceLoader.java | 10 +++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java index 1821722bc8c1f3..f645cbc37f0aac 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java @@ -71,8 +71,11 @@ static Map getProjectMap(MavenSession session) { } final Map projectModels = new HashMap<>(allProjects.size()); for (MavenProject mp : allProjects) { - mp.getOriginalModel().setPomFile(mp.getFile()); - projectModels.put(mp.getBasedir().toPath(), mp.getOriginalModel()); + final Model model = mp.getOriginalModel(); + model.setPomFile(mp.getFile()); + // activated profiles or custom extensions may have overridden the build defaults + model.setBuild(mp.getModel().getBuild()); + projectModels.put(mp.getBasedir().toPath(), model); } return projectModels; } 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 c2fa020ce577db..9b8e77720bf363 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 @@ -380,7 +380,7 @@ public WorkspaceModule toWorkspaceModule(BootstrapMavenContext ctx) { DefaultArtifactSources src = null; if (e.getGoals().contains(ArtifactCoords.TYPE_JAR)) { src = processJarPluginExecutionConfig(e.getConfiguration(), false); - addDefaultSourceSet &= !e.getId().equals("default-jar"); + addDefaultSourceSet &= !(src != null && e.getId().equals("default-jar")); } else if (e.getGoals().contains("test-jar")) { src = processJarPluginExecutionConfig(e.getConfiguration(), true); } 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 9e2587ee65a3bc..588b2766a00f9a 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 @@ -153,12 +153,16 @@ private LocalProject loadAndCacheProject(Path pomFile) throws BootstrapMavenExce } private Model rawModel(Path pomFile) throws BootstrapMavenException { - Model rawModel = rawModelCache.getOrDefault(pomFile.getParent(), - modelProvider == null ? null : modelProvider.apply(pomFile.getParent())); + final Path moduleDir = pomFile.getParent(); + Model rawModel = rawModelCache.get(moduleDir); + if (rawModel != null) { + return rawModel; + } + rawModel = modelProvider == null ? null : modelProvider.apply(moduleDir); if (rawModel == null) { rawModel = readModel(pomFile); } - rawModelCache.put(pomFile.getParent(), rawModel); + rawModelCache.put(moduleDir, rawModel); return rawModel; }