diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/DependencyInProfileActiveByDefaultRawModelBuilderTest.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/DependencyInProfileActiveByDefaultRawModelBuilderTest.java index e6ce88e6e34f1..83e92a4775570 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/DependencyInProfileActiveByDefaultRawModelBuilderTest.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/DependencyInProfileActiveByDefaultRawModelBuilderTest.java @@ -96,8 +96,8 @@ protected void assertAppModel(ApplicationModel model) { assertThat(d).isNotNull(); assertThat(d.isRuntimeCp()).isTrue(); assertThat(d.isDeploymentCp()).isTrue(); - assertThat(d.isWorkspaceModule()).isFalse(); // limitation of the raw pom-based workspace discovery - assertThat(d.isReloadable()).isFalse(); + assertThat(d.isWorkspaceModule()).isTrue(); + assertThat(d.isReloadable()).isTrue(); assertThat(d.isRuntimeExtensionArtifact()).isFalse(); d = deps.get("common-library"); @@ -105,7 +105,7 @@ protected void assertAppModel(ApplicationModel model) { assertThat(d.isRuntimeCp()).isTrue(); assertThat(d.isDeploymentCp()).isTrue(); assertThat(d.isWorkspaceModule()).isTrue(); - assertThat(d.isReloadable()).isFalse(); // since it's a dependency of a non-reloadable module + assertThat(d.isReloadable()).isTrue(); assertThat(d.isRuntimeExtensionArtifact()).isFalse(); d = deps.get("ext-a"); 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..e564125300ea1 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 @@ -219,8 +219,22 @@ private Path getParentPom(Path projectPom, Model rawModel) { } private LocalProject loadProjectModules(LocalProject project, String skipModule) throws BootstrapMavenException { - final List modules = project.getModelBuildingResult() == null ? project.getRawModel().getModules() - : project.getModelBuildingResult().getEffectiveModel().getModules(); + final List modules; + if (project.getModelBuildingResult() == null) { + var projectModel = project.getRawModel(); + List combinedList = null; + for (var profile : projectModel.getProfiles()) { + if (!profile.getModules().isEmpty()) { + if (combinedList == null) { + combinedList = new ArrayList<>(projectModel.getModules()); + } + combinedList.addAll(profile.getModules()); + } + } + modules = combinedList == null ? projectModel.getModules() : combinedList; + } else { + modules = project.getModelBuildingResult().getEffectiveModel().getModules(); + } if (!modules.isEmpty()) { for (String module : modules) { if (module.equals(skipModule)) { diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/workspace/test/LocalWorkspaceDiscoveryTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/workspace/test/LocalWorkspaceDiscoveryTest.java index 3a2e018bf0a0d..d284a1d0f2a83 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/workspace/test/LocalWorkspaceDiscoveryTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/workspace/test/LocalWorkspaceDiscoveryTest.java @@ -204,11 +204,11 @@ public void nonParentAggregator() throws Exception { } @Test - public void loadModulesInProfiles() throws Exception { + public void loadEffectiveModelBuilderModulesInProfiles() throws Exception { final URL moduleUrl = Thread.currentThread().getContextClassLoader() .getResource("modules-in-profiles/integration-tests/rest-tests"); assertNotNull(moduleUrl); - final Path moduleDir = Paths.get(moduleUrl.toURI()); + final Path moduleDir = Path.of(moduleUrl.toURI()); final LocalProject module1 = new BootstrapMavenContext(BootstrapMavenContext.config() .setEffectiveModelBuilder(true) @@ -225,6 +225,28 @@ public void loadModulesInProfiles() throws Exception { assertEquals(6, ws.getProjects().size()); } + @Test + public void loadModulesInProfiles() throws Exception { + final URL moduleUrl = Thread.currentThread().getContextClassLoader() + .getResource("modules-in-profiles/integration-tests/rest-tests"); + assertNotNull(moduleUrl); + final Path moduleDir = Path.of(moduleUrl.toURI()); + + final LocalProject module1 = new BootstrapMavenContext(BootstrapMavenContext.config() + .setCurrentProject(moduleDir.toString())) + .getCurrentProject(); + final LocalWorkspace ws = module1.getWorkspace(); + + assertNotNull(ws.getProject("org.acme", "quarkus-quickstart-multimodule-parent")); + assertNotNull(ws.getProject("org.acme", "quarkus-quickstart-multimodule-html")); + assertNotNull(ws.getProject("org.acme", "quarkus-quickstart-multimodule-main")); + assertNotNull(ws.getProject("org.acme", "quarkus-quickstart-multimodule-rest")); + assertNotNull(ws.getProject("org.acme", "acme-integration-tests")); + assertNotNull(ws.getProject("org.acme", "acme-rest-tests")); + assertNotNull(ws.getProject("org.acme", "other")); + assertEquals(7, ws.getProjects().size()); + } + @Test public void loadOverlappingWorkspaceLayout() throws Exception { final URL moduleUrl = Thread.currentThread().getContextClassLoader() diff --git a/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/other/pom.xml b/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/other/pom.xml new file mode 100644 index 0000000000000..21cefbb070e15 --- /dev/null +++ b/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/other/pom.xml @@ -0,0 +1,9 @@ + + + 4.0.0 + + org.acme + other + 1.0-SNAPSHOT + pom + \ No newline at end of file diff --git a/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/pom.xml b/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/pom.xml index 37585c5021da9..dea1f2780cf99 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/pom.xml +++ b/independent-projects/bootstrap/maven-resolver/src/test/resources/modules-in-profiles/pom.xml @@ -43,5 +43,11 @@ rest + + other + + other + +