Skip to content

Commit

Permalink
Use the effective Maven project build config when initializing source…
Browse files Browse the repository at this point in the history
…s and classes paths for dev mode

(cherry picked from commit 56408ec)
  • Loading branch information
aloubyansky authored and gsmet committed Feb 15, 2023
1 parent 703be26 commit 72c024f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ static Map<Path, Model> getProjectMap(MavenSession session) {
}
final Map<Path, Model> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ public void testThatTheApplicationIsReloadedOnJavaChange() throws MavenInvocatio
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));
}

@Test
public void testCustomOutputDirSetInProfile() throws MavenInvocationException, IOException {
testDir = initProject("projects/classic", "projects/project-classic-custom-output-dir");
runAndCheck("-PcustomOutputDir");
}

@Test
public void testThatNonExistentSrcDirCanBeAdded() throws MavenInvocationException, IOException {
testDir = initProject("projects/classic", "projects/project-classic-run-java-change");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,11 @@
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
<profile>
<id>customOutputDir</id>
<build>
<directory>target-other</directory>
</build>
</profile>
</profiles>
</project>

0 comments on commit 72c024f

Please sign in to comment.