Skip to content

Commit

Permalink
Merge pull request quarkusio#34795 from aloubyansky/load-all-workspac…
Browse files Browse the repository at this point in the history
…e-modules

Discover all the project modules from all the Maven profiles by default
  • Loading branch information
aloubyansky authored Jul 18, 2023
2 parents dc120ff + 87afa32 commit e43f855
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ 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");
assertThat(d).isNotNull();
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,22 @@ private Path getParentPom(Path projectPom, Model rawModel) {
}

private LocalProject loadProjectModules(LocalProject project, String skipModule) throws BootstrapMavenException {
final List<String> modules = project.getModelBuildingResult() == null ? project.getRawModel().getModules()
: project.getModelBuildingResult().getEffectiveModel().getModules();
final List<String> modules;
if (project.getModelBuildingResult() == null) {
var projectModel = project.getRawModel();
List<String> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.acme</groupId>
<artifactId>other</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@
<module>rest</module>
</modules>
</profile>
<profile>
<id>other</id>
<modules>
<module>other</module>
</modules>
</profile>
</profiles>
</project>

0 comments on commit e43f855

Please sign in to comment.