Repository: quarkusio/quarkus
Issue: quarkus-config: Maven-Property conflicts with 'prefix' (Regression since Quarkus 2.12)

### Describe the bug

__Regression Quarkus 2.11 -> Quarkus 2.12__

If the `prefix` in `ConfigMapping` has the same name as a Maven-Property, you will get the following error on startup (see reproducer):

```bash
2022-09-13 06:54:14,561 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): io.smallrye.config.ConfigValidationException: Configuration validation failed:
	xyz.version does not map to any root
	at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:967)
	at io.smallrye.config.ConfigMappingProvider.lambda$mapConfiguration$3(ConfigMappingProvider.java:923)
	at io.smallrye.config.SecretKeys.lambda$doUnlocked$0(SecretKeys.java:20)
	at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:29)
	at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:19)
	at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:923)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:450)
	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
	at java.base/java.lang.Thread.run(Thread.java:829)

2022-09-13 06:54:14,561 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): io.smallrye.config.ConfigValidationException: Configuration validation failed:
	xyz.version does not map to any root
	at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:967)
	at io.smallrye.config.ConfigMappingProvider.lambda$mapConfiguration$3(ConfigMappingProvider.java:923)
	at io.smallrye.config.SecretKeys.lambda$doUnlocked$0(SecretKeys.java:20)
	at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:29)
	at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:19)
	at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:923)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:450)
	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
	at java.base/java.lang.Thread.run(Thread.java:829)

2022-09-13 06:54:14,562 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2022-09-13 06:54:14,562 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
Press [space] to restart, [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle test output, [h] for more options>
```

Note: At the moment i cannot upgrade my Quarkus projects to Quarkus 2.12.1.Final because the property is defined in a parent pom over which i have no control.



### Expected behavior

_No response_

### Actual behavior

_No response_

### How to Reproduce?

[reproducer.zip](https://github.com/quarkusio/quarkus/files/9553721/reproducer.zip)


### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

Java 11

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

Quarkus 2.12.1.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Maven

### Additional information

_No response_

Changed files:
core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java
devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java
index 65d7f096a8f..9fd912d9e7c 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java
@@ -878,13 +878,16 @@ private Converter<?> getConverter(SmallRyeConfig config, Field field, ConverterT
          * We collect all properties from eligible ConfigSources, because Config#getPropertyNames exclude the active
          * profiled properties, meaning that the property is written in the default config source without the profile
          * prefix. This may cause issues if we run with a different profile and fallback to defaults.
-         *
+         * <br>
          * We also filter the properties coming from the System with the registered roots, because we don't want to
          * record properties set by the compiling JVM (or other properties that are only related to the build).
+         * <br>
+         * Properties coming from the Environment are ignored.
          */
         private Set<String> getAllProperties(final Set<String> registeredRoots) {
             Set<String> properties = new HashSet<>();
             for (ConfigSource configSource : config.getConfigSources()) {
+                // This is a BuildTimeSysPropConfigSource
                 if (configSource instanceof SysPropConfigSource) {
                     for (String propertyName : configSource.getProperties().keySet()) {
                         NameIterator ni = new NameIterator(propertyName);
@@ -893,6 +896,7 @@ private Set<String> getAllProperties(final Set<String> registeredRoots) {
                         }
                     }
                 } else {
+                    // The BuildTimeEnvConfigSource returns an empty Set
                     properties.addAll(configSource.getPropertyNames());
                 }
             }
@@ -906,10 +910,10 @@ private Set<String> getAllProperties(final Set<String> registeredRoots) {
          * Use this Config instance to record the runtime default values. We cannot use the main Config
          * instance because it may record values coming from the EnvSource in build time. Environment variable values
          * may be completely different between build and runtime, so it doesn't make sense to record these.
-         *
+         * <br>
          * We do exclude the properties coming from the EnvSource, but a call to getValue may still provide a result
          * coming from the EnvSource, so we need to exclude it from the sources when recording values for runtime.
-         *
+         * <br>
          * We also do not want to completely exclude the EnvSource, because it may provide values for the build. This
          * is only specific when recording the defaults.
          *
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 bfd2968ee22..e9b1b274eb1 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
@@ -1,5 +1,7 @@
 package io.quarkus.maven;
 
+import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX;
+import static io.smallrye.common.expression.Expression.Flag.NO_TRIM;
 import static java.util.function.Predicate.not;
 import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
 import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
@@ -105,6 +107,7 @@
 import io.quarkus.maven.dependency.ResolvedDependency;
 import io.quarkus.paths.PathList;
 import io.quarkus.runtime.LaunchMode;
+import io.smallrye.common.expression.Expression;
 
 /**
  * The dev mojo, that runs a quarkus app in a forked process. A background compilation process is launched and any changes are
@@ -983,7 +986,31 @@ private QuarkusDevModeLauncher newLauncher() throws Exception {
         }
 
         builder.projectDir(project.getFile().getParentFile());
-        builder.buildSystemProperties((Map) project.getProperties());
+
+        Properties projectProperties = project.getProperties();
+        Map<String, String> effectiveProperties = new HashMap<>();
+        for (String name : projectProperties.stringPropertyNames()) {
+            if (name.startsWith("quarkus.")) {
+                effectiveProperties.put(name, projectProperties.getProperty(name));
+            }
+        }
+
+        // Add other properties that may be required for expansion
+        for (String value : effectiveProperties.values()) {
+            for (String reference : Expression.compile(value, LENIENT_SYNTAX, NO_TRIM).getReferencedStrings()) {
+                String referenceValue = session.getUserProperties().getProperty(reference);
+                if (referenceValue != null) {
+                    effectiveProperties.put(reference, referenceValue);
+                    continue;
+                }
+
+                referenceValue = projectProperties.getProperty(reference);
+                if (referenceValue != null) {
+                    effectiveProperties.put(reference, referenceValue);
+                }
+            }
+        }
+        builder.buildSystemProperties(effectiveProperties);
 
         builder.applicationName(project.getArtifactId());
         builder.applicationVersion(project.getVersion());