Skip to content

Commit 110fc5f

Browse files
authored
Merge pull request #31803 from aloubyansky/fix-npe-loading-workspace-modules
A test to make sure non-existing modules are ignored during workspace discovery
2 parents 8b8c57b + e40820e commit 110fc5f

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/workspace/test/LocalWorkspaceDiscoveryTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,24 @@ public void loadWorkspaceWithDirBreaks() throws Exception {
227227
assertEquals(4, ws.getProjects().size());
228228
}
229229

230+
@Test
231+
public void loadWorkspaceWithMissingModule() throws Exception {
232+
final URL projectUrl = Thread.currentThread().getContextClassLoader().getResource("workspace-missing-module/root");
233+
assertNotNull(projectUrl);
234+
final Path rootProjectDir = Paths.get(projectUrl.toURI());
235+
assertTrue(Files.exists(rootProjectDir));
236+
final Path nestedProjectDir = rootProjectDir.resolve("module1");
237+
assertTrue(Files.exists(nestedProjectDir));
238+
239+
final LocalWorkspace ws = new BootstrapMavenContext(BootstrapMavenContext.config()
240+
.setCurrentProject(nestedProjectDir.toString()))
241+
.getWorkspace();
242+
243+
assertNotNull(ws.getProject("org.acme", "module1"));
244+
assertNotNull(ws.getProject("org.acme", "root"));
245+
assertEquals(2, ws.getProjects().size());
246+
}
247+
230248
@Test
231249
public void loadWorkspaceRootWithNoModules() throws Exception {
232250
final URL projectUrl = Thread.currentThread().getContextClassLoader().getResource("workspace-root-no-module/root");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.acme</groupId>
7+
<artifactId>root</artifactId>
8+
<version>1.0</version>
9+
</parent>
10+
11+
<artifactId>module1</artifactId>
12+
<packaging>pom</packaging>
13+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.acme</groupId>
6+
<artifactId>root</artifactId>
7+
<version>1.0</version>
8+
<packaging>pom</packaging>
9+
10+
<modules>
11+
<module>module1</module>
12+
<module>module2</module>
13+
</modules>
14+
</project>

0 commit comments

Comments
 (0)