Repository: quarkusio/quarkus
Issue: Continuous testing fails when `@QuarkusMainTest` and a `@ConfigMapping` are involved

### Describe the bug

Running a test annotated with `@QuarkusMainTest` in continuous testing mode where another test tests a config mapping defined by `@ConfigMapping` causes the test to fail with a `ClassCastException`:

```
Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253)
        at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
```

It is important that the test testing the `@ConfigMapping` is run before the `@QuarkusMainTest`. The other way round the behavior couldn't be observed.

The tests pass when run with `./mvnw clean verify`


### Expected behavior

Tests passing when run with `./mvnw clean verify` also pass when run in continuous testing mode.

### Actual behavior

When a test using an injected `@ConfigMapping` is run before a `@QuarkusMainTest` the `@QuarkusMainTest` fails with a class cast exception:

```
Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253)
        at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
```

### How to Reproduce?

1. Download the demo at tag [QuarkusMainTestFailWithConfigMapping](https://github.com/itbh-at/quarkus-main-test/releases/tag/QuarkusMainTestFailWithConfigMapping)
2. Run `quarkus dev`
3. Start tests -> fail
4. Remove the `@QuarkusMainTest` -> pass
5. Add again the `@QuarkusMainTest` and remove `ConfigurationTest` -> pass
6. Add `ConfigurationTest` again
7. Rename `ConfigurationTest.java` to `GreetingConfigurationTest.java` to ensure it is run after the `@QuarkusMainTest` in `GreetingCommandTest.java`
8. Run the test in `quarkus dev` -> fail, but not because of the `ClassCastException` but because of what is described in #22790
8. Make sure the app looks the same as after the download and exit `quarkus dev`
9. Run `./mvnw clean verify` -> pass

### Output of `uname -a` or `ver`

Darwin cdh 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64

### Output of `java -version`

java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.6.2.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: ~/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1 Java version: 17, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home Default locale: de_AT, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "aarch64", family: "mac"

### Additional information

_No response_

Changed files:
core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java
index 0793c514d43..0d5f07a2337 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java
@@ -72,7 +72,6 @@
 import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix;
 import io.smallrye.config.ConfigSourceFactory;
 import io.smallrye.config.PropertiesLocationConfigSourceFactory;
-import io.smallrye.config.SmallRyeConfig;
 
 public class ConfigGenerationBuildStep {
 
@@ -238,7 +237,7 @@ public void setupConfigOverride(
     public void watchConfigFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> watchedFiles) {
         List<String> configWatchedFiles = new ArrayList<>();
 
-        SmallRyeConfig config = (SmallRyeConfig) ConfigProvider.getConfig();
+        Config config = ConfigProvider.getConfig();
         String userDir = System.getProperty("user.dir");
 
         // Main files