Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the effective Maven project build config when initializing sources and classes paths for dev mode #31099

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>