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 326fd9c0b924a..2e6d5e4b0a1ca 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 @@ -1018,28 +1018,40 @@ private Converter getConverter(SmallRyeConfig config, Field field, ConverterT */ private Set getAllProperties(final Set registeredRoots) { Set properties = new HashSet<>(); + + // Get all properties, including the ones generated by interceptors, but these do not include profiles for (String property : config.getPropertyNames()) { properties.add(property); } + Set propertiesToRemove = new HashSet<>(); + Set propertiesToAdd = new HashSet<>(); + + // Get properties per source to collect profiled properties and exclude properties that are build related for (ConfigSource configSource : config.getConfigSources()) { if (configSource instanceof SysPropConfigSource || configSource instanceof EnvConfigSource || "PropertiesConfigSource[source=Build system]".equals(configSource.getName())) { for (String property : configSource.getPropertyNames()) { NameIterator ni = new NameIterator(property); if (ni.hasNext() && PropertiesUtil.isPropertyInRoot(registeredRoots, ni)) { - properties.add(property); + propertiesToAdd.add(property); } else { - properties.remove(property); + propertiesToRemove.add(property); if (configSource instanceof EnvConfigSource) { - properties.remove(StringUtil.toLowerCaseAndDotted(property)); + propertiesToRemove.add(StringUtil.toLowerCaseAndDotted(property)); } } } } else { - properties.addAll(configSource.getPropertyNames()); + propertiesToAdd.addAll(configSource.getPropertyNames()); } } + + // A property may exist in an excluded source and an include source. We don't have a way to know, so we + // just remove the excluded ones and add the ones to be included, so the property is back there again + properties.removeAll(propertiesToRemove); + properties.addAll(propertiesToAdd); + return properties; }