Repository: quarkusio/quarkus
Issue: Erroneous warnings after #30620

### Describe the bug

https://github.com/quarkusio/quarkus/pull/30620 results in erroneous warnings, e.g.:

```
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.smallrye-jwt.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
```

while `quarkus-smallrye-jwt` is properly set as a dependency.

### Expected behavior

Build should complete without warnings for properly configured apps.

### Actual behavior

Build completes but prints the following erroneous warnings:

```
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.native.additional-build-args" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.endpoint" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.sampler-type" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.ssl.native" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.smallrye-jwt.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.sampler-param" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.service-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.rest-client."com.example.quarkus.client.Service".url" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo

```

### How to Reproduce?

```
git clone https://github.com/Karm/mandrel-integration-tests.git
cd mandrel-integration-tests/apps/quarkus-full-microprofile
mvn clean package -Dquarkus.version=999-SNAPSHOT
```

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

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

b1ecd0b065bdc0f783b55581ea872aee38152db3

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

_No response_

### Additional information

_No response_

Changed files:
core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java
integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.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 32918f8aead..1af98cc2cd3 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
@@ -443,6 +443,7 @@ ReadResult run() {
                 if (ni.hasNext() && PropertiesUtil.isPropertyInRoot(registeredRoots, ni)) {
                     // build time patterns
                     Container matched = buildTimePatternMap.match(ni);
+                    boolean knownProperty = matched != null;
                     if (matched instanceof FieldContainer) {
                         ConfigValue configValue = config.getConfigValue(propertyName);
                         if (configValue.getValue() != null) {
@@ -471,6 +472,7 @@ ReadResult run() {
                     // build time (run time visible) patterns
                     ni.goToStart();
                     matched = buildTimeRunTimePatternMap.match(ni);
+                    knownProperty = knownProperty || matched != null;
                     if (matched instanceof FieldContainer) {
                         ConfigValue configValue = config.getConfigValue(propertyName);
                         if (configValue.getValue() != null) {
@@ -501,6 +503,7 @@ ReadResult run() {
                     // run time patterns
                     ni.goToStart();
                     matched = runTimePatternMap.match(ni);
+                    knownProperty = knownProperty || matched != null;
                     if (matched != null) {
                         // it's a run-time default (record for later)
                         ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName));
@@ -511,6 +514,7 @@ ReadResult run() {
                     // also check for the bootstrap properties since those need to be added to runTimeDefaultValues as well
                     ni.goToStart();
                     matched = bootstrapPatternMap.match(ni);
+                    knownProperty = knownProperty || matched != null;
                     if (matched != null) {
                         // it's a run-time default (record for later)
                         ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName));
@@ -519,7 +523,7 @@ ReadResult run() {
                         }
                     }
 
-                    if (matched == null) {
+                    if (!knownProperty) {
                         unknownBuildProperties.add(propertyName);
                     }
                 } else {
diff --git a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java
index 490a1ff9f18..2bb9c6a755c 100644
--- a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java
+++ b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java
@@ -1,10 +1,12 @@
 package io.quarkus.extest;
 
-import static java.util.Arrays.asList;
+import static java.util.stream.Collectors.toSet;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 
@@ -28,11 +30,22 @@ public class UnknownBuildConfigTest {
     void unknownBuildConfig() {
         List<LogRecord> logRecords = prodModeTestResults.getRetainedBuildLogRecords();
 
-        Optional<LogRecord> unknownBuildKey = logRecords.stream()
-                .filter(logRecord -> asList(Optional.ofNullable(logRecord.getParameters()).orElse(new Object[0]))
-                        .contains("quarkus.build.unknown.prop"))
-                .findFirst();
-        assertTrue(unknownBuildKey.isPresent());
-        assertTrue(unknownBuildKey.get().getMessage().startsWith("Unrecognized configuration key"));
+        // These are the expected unknown properties in the test extension. This could probably be improved, because
+        // these are generated with the rename test. If there is a change we know that something happened.
+        Set<Object> unrecognized = logRecords.stream()
+                .filter(logRecord -> logRecord.getMessage().startsWith("Unrecognized configuration key"))
+                .map(logRecord -> Optional.ofNullable(logRecord.getParameters())
+                        .map(parameters -> parameters[0])
+                        .orElse(new Object[0]))
+                .collect(toSet());
+
+        assertEquals(7, logRecords.size());
+        assertTrue(unrecognized.contains("quarkus.unknown.prop"));
+        assertTrue(unrecognized.contains("quarkus.build.unknown.prop"));
+        assertTrue(unrecognized.contains("quarkus.rename-old.prop"));
+        assertTrue(unrecognized.contains("quarkus.rename-old.only-in-new"));
+        assertTrue(unrecognized.contains("quarkus.rename-old.only-in-old"));
+        assertTrue(unrecognized.contains("quarkus.rename-old.in-both"));
+        assertTrue(unrecognized.contains("quarkus.rename-old.with-default"));
     }
 }