Repository: quarkusio/quarkus
Issue: Index doesn't pick up new interface implementations during dev mode

### Describe the bug

I'm encountering an issue with my extension (https://github.com/quarkiverse/quarkus-operator-sdk) and dev mode: the extension allows you to bypass a lot of boilerplate by only providing implementations of a given interface and does the wiring needed to create a functioning (CLI) application.

I create my app using my extension with no initial classes, my extension processor automatically creates some objects that try to register known implementations of a given interface via a `StartupEvent` listener.

No implementations => nothing to do => my extension throws an exception to tell the user to add some implementations: all good

If I now add some implementation with dev mode still running and force the app to restart, my extension still fails to find any implementation and therefore fails the app again.

### Expected behavior

I'd expect the added classes implementing the target interface to be visible by my extension without having to exit the dev mode.

### Actual behavior

New implementations of the interface don't appear to be picked up by the index.

### How to Reproduce?

1. `git clone https://github.com/metacosm/dev-mode-bug.git`
2. `git co step-1`: initial state, no `ResourceController` implementation
3. `mvn quarkus:dev` => `ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): io.javaoperatorsdk.operator.OperatorException: No ResourceController exists. Exiting!`
4. In another terminal to keep dev mode running: `git co step-2` to move the code to a state where a `ResourceController` implementation exists
5. In first terminal, press `space` to restart the app, observe that we still get the same exception

### Output of `uname -a` or `ver`

Darwin wakizashi.home 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

### Output of `java -version`

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

### GraalVM version (if different from Java)

Irrelevant

### Quarkus version or git rev

2.1.3

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

mvn --version Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f) Maven home: /usr/local/Cellar/maven/3.8.2/libexec Java version: 11.0.11, vendor: AdoptOpenJDK, runtime: /Users/claprun/.sdkman/candidates/java/11.0.11.hs-adpt Default locale: en_FR, platform encoding: UTF-8 OS name: "mac os x", version: "11.5", arch: "x86_64", family: "mac"

### Additional information

_No response_

Changed files:
devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java, integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java

diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
index abeab532960..c015ef36958 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
@@ -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()
diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java
index 475a22423ad..22e5190d88f 100644
--- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java
+++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java
@@ -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");