Skip to content

Commit

Permalink
A test to make sure non-existing modules are ignored during workspace…
Browse files Browse the repository at this point in the history
… discovery
  • Loading branch information
aloubyansky committed Mar 13, 2023
1 parent 3a81f62 commit bfd0441
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ private LocalProject loadParentProject(Path projectPom, final Model rawModel) th
}

private Path getParentPom(Path projectPom, Model rawModel) {
if (rawModel == null) {
return null;
}
Path parentPom = null;
final Path projectDir = projectPom.getParent();
final Parent parent = rawModel.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,24 @@ public void loadWorkspaceWithDirBreaks() throws Exception {
assertEquals(4, ws.getProjects().size());
}

@Test
public void loadWorkspaceWithMissingModule() throws Exception {
final URL projectUrl = Thread.currentThread().getContextClassLoader().getResource("workspace-missing-module/root");
assertNotNull(projectUrl);
final Path rootProjectDir = Paths.get(projectUrl.toURI());
assertTrue(Files.exists(rootProjectDir));
final Path nestedProjectDir = rootProjectDir.resolve("module1");
assertTrue(Files.exists(nestedProjectDir));

final LocalWorkspace ws = new BootstrapMavenContext(BootstrapMavenContext.config()
.setCurrentProject(nestedProjectDir.toString()))
.getWorkspace();

assertNotNull(ws.getProject("org.acme", "module1"));
assertNotNull(ws.getProject("org.acme", "root"));
assertEquals(2, ws.getProjects().size());
}

@Test
public void loadWorkspaceRootWithNoModules() throws Exception {
final URL projectUrl = Thread.currentThread().getContextClassLoader().getResource("workspace-root-no-module/root");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.acme</groupId>
<artifactId>root</artifactId>
<version>1.0</version>
</parent>

<artifactId>module1</artifactId>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.acme</groupId>
<artifactId>root</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<modules>
<module>module1</module>
<module>module2</module>
</modules>
</project>

0 comments on commit bfd0441

Please sign in to comment.