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

[2.16] A test to make sure non-existing modules are ignored during workspace discovery #31804

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 @@ -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>