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

Handle creating the src dir in dev mode #19706

Merged
merged 1 commit into from
Aug 27, 2021
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
13 changes: 2 additions & 11 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,22 +653,13 @@ private void addProject(MavenDevModeLauncher.Builder builder, LocalProject local
if (mavenProject == null) {
projectDirectory = localProject.getDir().toAbsolutePath().toString();
Path sourcePath = localProject.getSourcesSourcesDir().toAbsolutePath();
if (Files.isDirectory(sourcePath)) {
sourcePaths = Collections.singleton(sourcePath);
} else {
sourcePaths = Collections.emptySet();
}
sourcePaths = Collections.singleton(sourcePath);
Path testSourcePath = localProject.getTestSourcesSourcesDir().toAbsolutePath();
if (Files.isDirectory(testSourcePath)) {
testSourcePaths = Collections.singleton(testSourcePath);
} else {
testSourcePaths = Collections.emptySet();
}
testSourcePaths = Collections.singleton(testSourcePath);
} else {
projectDirectory = mavenProject.getBasedir().getPath();
sourcePaths = mavenProject.getCompileSourceRoots().stream()
.map(Paths::get)
.filter(Files::isDirectory)
.map(Path::toAbsolutePath)
.collect(Collectors.toCollection(LinkedHashSet::new));
testSourcePaths = mavenProject.getTestCompileSourceRoots().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,37 @@ public void testThatTheApplicationIsReloadedOnJavaChange() throws MavenInvocatio
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));
}

@Test
public void testThatNonExistentSrcDirCanBeAdded() throws MavenInvocationException, IOException {
testDir = initProject("projects/classic", "projects/project-classic-run-java-change");

File sourceDir = new File(testDir, "src/main/java");
File sourceDirMoved = new File(testDir, "src/main/java-moved");
if (!sourceDir.renameTo(sourceDirMoved)) {
Assertions.fail("move failed");
}
//we need this to make run and check work
File hello = new File(testDir, "src/main/resources/META-INF/resources/app/hello");
hello.getParentFile().mkdir();
try (var o = new FileOutputStream(hello)) {
o.write("hello".getBytes(StandardCharsets.UTF_8));
}

runAndCheck();
hello.delete();
if (!DevModeTestUtils.getHttpResponse("/app/hello", 404)) {
Assertions.fail("expected resource to be deleted");
}
if (!sourceDirMoved.renameTo(sourceDir)) {
Assertions.fail("move failed");
}

// Wait until we get "hello"
await()
.pollDelay(100, TimeUnit.MILLISECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello"));
}

@Test
public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationException, IOException {
testDir = initProject("projects/classic-inst", "projects/project-intrumentation-reload");
Expand Down