From 848bfb4bd074a873097a158431172388d675ca1b Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Tue, 30 Jul 2024 16:11:48 +0100 Subject: [PATCH] Update SmallRye Config to 3.10.0 --- bom/application/pom.xml | 2 +- .../quarkus/deployment/ExtensionLoader.java | 8 +- .../builditem/ConfigMappingBuildItem.java | 6 +- .../BuildTimeConfigurationReader.java | 77 +++++++++---------- .../configuration/ConfigMappingUtils.java | 21 ++--- .../RunTimeConfigurationGenerator.java | 8 +- .../steps/ConfigDescriptionBuildStep.java | 6 +- .../steps/ConfigGenerationBuildStep.java | 26 +++---- .../runtime/configuration/Substitutions.java | 8 +- .../arc/deployment/ConfigBuildStep.java | 10 +-- .../IndexedPropertiesInjectionTest.java | 2 +- .../quarkus/arc/runtime/ConfigRecorder.java | 4 +- .../QuarkusComponentTestExtension.java | 14 ++-- 13 files changed, 91 insertions(+), 101 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index c9b791cf476a1..4de3284182739 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -48,7 +48,7 @@ 2.0 3.1.2 2.8.0 - 3.9.1 + 3.10.0 4.1.0 4.0.0 3.13.0 diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java index 6d7bc5bd526c9..963027bc89c1b 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java @@ -101,7 +101,7 @@ import io.quarkus.runtime.annotations.Recorder; import io.quarkus.runtime.configuration.QuarkusConfigFactory; import io.quarkus.runtime.util.HashUtil; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.SmallRyeConfig; /** @@ -172,7 +172,7 @@ public String getId() { // this has to be an identity hash map else the recorder will get angry Map rootFields = new IdentityHashMap<>(); - Map mappingClasses = new IdentityHashMap<>(); + Map mappingClasses = new IdentityHashMap<>(); for (Map.Entry, Object> entry : proxies.entrySet()) { // ConfigRoot RootDefinition root = readResult.getAllRootsByClass().get(entry.getKey()); @@ -182,7 +182,7 @@ public String getId() { } // ConfigMapping - ConfigClassWithPrefix mapping = readResult.getAllMappings().get(entry.getKey()); + ConfigClass mapping = readResult.getAllMappings().get(entry.getKey()); if (mapping != null) { mappingClasses.put(entry.getValue(), mapping); continue; @@ -210,7 +210,7 @@ public boolean canHandleObject(final Object obj, final boolean staticInit) { ObjectLoader mappingLoader = new ObjectLoader() { @Override public ResultHandle load(final BytecodeCreator body, final Object obj, final boolean staticInit) { - ConfigClassWithPrefix mapping = mappingClasses.get(obj); + ConfigClass mapping = mappingClasses.get(obj); MethodDescriptor getConfig = MethodDescriptor.ofMethod(ConfigProvider.class, "getConfig", Config.class); ResultHandle config = body.invokeStaticMethod(getConfig); MethodDescriptor getMapping = MethodDescriptor.ofMethod(SmallRyeConfig.class, "getConfigMapping", diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigMappingBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigMappingBuildItem.java index 45274f49eb20a..23ff2f5074385 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigMappingBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigMappingBuildItem.java @@ -4,7 +4,7 @@ import io.quarkus.builder.item.MultiBuildItem; import io.quarkus.runtime.annotations.StaticInitSafe; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; public final class ConfigMappingBuildItem extends MultiBuildItem { private final Class configClass; @@ -27,8 +27,8 @@ public boolean isStaticInitSafe() { return configClass.isAnnotationPresent(StaticInitSafe.class); } - public ConfigClassWithPrefix toConfigClassWithPrefix() { - return new ConfigClassWithPrefix(configClass, prefix); + public ConfigClass toConfigClass() { + return new ConfigClass(configClass, prefix); } @Override 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 e493211f6336e..0903a5b88b568 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 @@ -6,8 +6,7 @@ import static io.quarkus.deployment.util.ReflectUtil.toError; import static io.quarkus.deployment.util.ReflectUtil.typeOfParameter; import static io.quarkus.deployment.util.ReflectUtil.unwrapInvocationTargetException; -import static io.quarkus.runtime.configuration.PropertiesUtil.isPropertyInRoots; -import static io.smallrye.config.ConfigMappings.ConfigClassWithPrefix.configClassWithPrefix; +import static io.smallrye.config.ConfigMappings.ConfigClass.configClass; import static io.smallrye.config.Expressions.withoutExpansion; import static io.smallrye.config.SmallRyeConfig.SMALLRYE_CONFIG_PROFILE; import static io.smallrye.config.SmallRyeConfig.SMALLRYE_CONFIG_PROFILE_PARENT; @@ -74,7 +73,7 @@ import io.quarkus.runtime.configuration.PropertiesUtil; import io.smallrye.config.ConfigMapping; import io.smallrye.config.ConfigMappings; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.ConfigValue; import io.smallrye.config.Converters; import io.smallrye.config.DefaultValuesConfigSource; @@ -119,10 +118,10 @@ private static List> collectConfigRoots(ClassLoader classLoader) throws final List allRoots; final List buildTimeVisibleRoots; - final List buildTimeMappings; - final List buildTimeRunTimeMappings; - final List runTimeMappings; - final List buildTimeVisibleMappings; + final List buildTimeMappings; + final List buildTimeRunTimeMappings; + final List runTimeMappings; + final List buildTimeVisibleMappings; final Set deprecatedProperties; final Set deprecatedRuntimeProperties; @@ -183,7 +182,7 @@ private BuildTimeConfigurationReader(ClassLoader classLoader, final List getAllRoots() { return allRoots; } - public List getBuildTimeMappings() { + public List getBuildTimeMappings() { return buildTimeMappings; } - public List getBuildTimeRunTimeMappings() { + public List getBuildTimeRunTimeMappings() { return buildTimeRunTimeMappings; } - public List getBuildTimeVisibleMappings() { + public List getBuildTimeVisibleMappings() { return buildTimeVisibleMappings; } @@ -401,8 +400,8 @@ public SmallRyeConfig initConfiguration(LaunchMode launchMode, Properties buildS new DefaultValuesConfigSource(platformProperties, "Quarkus platform", Integer.MIN_VALUE + 1000)); } - for (ConfigClassWithPrefix mapping : getBuildTimeVisibleMappings()) { - builder.withMapping(mapping.getKlass(), mapping.getPrefix()); + for (ConfigClass mapping : getBuildTimeVisibleMappings()) { + builder.withMapping(mapping); } builder.withInterceptors(buildConfigTracker); @@ -623,12 +622,12 @@ ReadResult run() { configSource -> unknownBuildProperties.removeAll(configSource.getPropertyNames())); // ConfigMappings - for (ConfigClassWithPrefix mapping : buildTimeVisibleMappings) { + for (ConfigClass mapping : buildTimeVisibleMappings) { objectsByClass.put(mapping.getKlass(), config.getConfigMapping(mapping.getKlass(), mapping.getPrefix())); } // Build Time Values Recording - for (ConfigClassWithPrefix mapping : buildTimeMappings) { + for (ConfigClass mapping : buildTimeMappings) { Set mappedProperties = ConfigMappings.mappedProperties(mapping, allProperties); for (String property : mappedProperties) { unknownBuildProperties.remove(property); @@ -640,7 +639,7 @@ ReadResult run() { } // Build Time and Run Time Values Recording - for (ConfigClassWithPrefix mapping : buildTimeRunTimeMappings) { + for (ConfigClass mapping : buildTimeRunTimeMappings) { Set mappedProperties = ConfigMappings.mappedProperties(mapping, allProperties); for (String property : mappedProperties) { unknownBuildProperties.remove(property); @@ -653,7 +652,7 @@ ReadResult run() { } // Run Time Values Recording - for (ConfigClassWithPrefix mapping : runTimeMappings) { + for (ConfigClass mapping : runTimeMappings) { Set mappedProperties = ConfigMappings.mappedProperties(mapping, allProperties); for (String property : mappedProperties) { unknownBuildProperties.remove(property); @@ -1234,10 +1233,10 @@ public static final class ReadResult { final List allRoots; final Map, RootDefinition> allRootsByClass; - final List buildTimeMappings; - final List buildTimeRunTimeMappings; - final List runTimeMappings; - final Map, ConfigClassWithPrefix> allMappings; + final List buildTimeMappings; + final List buildTimeRunTimeMappings; + final List runTimeMappings; + final Map, ConfigClass> allMappings; final Set unknownBuildProperties; final Set deprecatedRuntimeProperties; @@ -1277,15 +1276,15 @@ private static Map, RootDefinition> rootsToMap(Builder builder) { return map; } - private static Map, ConfigClassWithPrefix> mappingsToMap(Builder builder) { - Map, ConfigClassWithPrefix> map = new HashMap<>(); - for (ConfigClassWithPrefix mapping : builder.getBuildTimeMappings()) { + private static Map, ConfigClass> mappingsToMap(Builder builder) { + Map, ConfigClass> map = new HashMap<>(); + for (ConfigClass mapping : builder.getBuildTimeMappings()) { map.put(mapping.getKlass(), mapping); } - for (ConfigClassWithPrefix mapping : builder.getBuildTimeRunTimeMappings()) { + for (ConfigClass mapping : builder.getBuildTimeRunTimeMappings()) { map.put(mapping.getKlass(), mapping); } - for (ConfigClassWithPrefix mapping : builder.getRunTimeMappings()) { + for (ConfigClass mapping : builder.getRunTimeMappings()) { map.put(mapping.getKlass(), mapping); } return map; @@ -1331,19 +1330,19 @@ public Map, RootDefinition> getAllRootsByClass() { return allRootsByClass; } - public List getBuildTimeMappings() { + public List getBuildTimeMappings() { return buildTimeMappings; } - public List getBuildTimeRunTimeMappings() { + public List getBuildTimeRunTimeMappings() { return buildTimeRunTimeMappings; } - public List getRunTimeMappings() { + public List getRunTimeMappings() { return runTimeMappings; } - public Map, ConfigClassWithPrefix> getAllMappings() { + public Map, ConfigClass> getAllMappings() { return allMappings; } @@ -1377,9 +1376,9 @@ static class Builder { private ConfigPatternMap buildTimeRunTimePatternMap; private ConfigPatternMap runTimePatternMap; private List allRoots; - private List buildTimeMappings; - private List buildTimeRunTimeMappings; - private List runTimeMappings; + private List buildTimeMappings; + private List buildTimeRunTimeMappings; + private List runTimeMappings; private Set unknownBuildProperties; private Set deprecatedRuntimeProperties; private ConfigTrackingInterceptor buildConfigTracker; @@ -1465,29 +1464,29 @@ Builder setAllRoots(final List allRoots) { return this; } - List getBuildTimeMappings() { + List getBuildTimeMappings() { return buildTimeMappings; } - Builder setBuildTimeMappings(final List buildTimeMappings) { + Builder setBuildTimeMappings(final List buildTimeMappings) { this.buildTimeMappings = buildTimeMappings; return this; } - List getBuildTimeRunTimeMappings() { + List getBuildTimeRunTimeMappings() { return buildTimeRunTimeMappings; } - Builder setBuildTimeRunTimeMappings(final List buildTimeRunTimeMappings) { + Builder setBuildTimeRunTimeMappings(final List buildTimeRunTimeMappings) { this.buildTimeRunTimeMappings = buildTimeRunTimeMappings; return this; } - List getRunTimeMappings() { + List getRunTimeMappings() { return runTimeMappings; } - Builder setRunTimeMappings(final List runTimeMappings) { + Builder setRunTimeMappings(final List runTimeMappings) { this.runTimeMappings = runTimeMappings; return this; } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigMappingUtils.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigMappingUtils.java index 546572ed3ef28..32f567f0c38d7 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigMappingUtils.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigMappingUtils.java @@ -1,9 +1,8 @@ package io.quarkus.deployment.configuration; -import static io.smallrye.config.ConfigMappings.ConfigClassWithPrefix.configClassWithPrefix; +import static io.smallrye.config.ConfigMappings.ConfigClass.configClass; import static org.jboss.jandex.AnnotationTarget.Kind.CLASS; -import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -35,7 +34,7 @@ import io.smallrye.config.ConfigMappingInterface.Property; import io.smallrye.config.ConfigMappingLoader; import io.smallrye.config.ConfigMappingMetadata; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; public class ConfigMappingUtils { @@ -64,7 +63,7 @@ public static void processConfigClasses( Class configClass = toClass(target.asClass().name()); String prefix = Optional.ofNullable(annotationPrefix).map(AnnotationValue::asString).orElse(""); Kind configClassKind = getConfigClassType(instance); - processConfigClass(configClassWithPrefix(configClass, prefix), configClassKind, true, combinedIndex, + processConfigClass(configClass(configClass, prefix), configClassKind, true, combinedIndex, generatedClasses, reflectiveClasses, reflectiveMethods, configClasses, additionalConstrainedClasses); } } @@ -81,7 +80,7 @@ public static void processConfigMapping( } public static void processExtensionConfigMapping( - ConfigClassWithPrefix configClass, + ConfigClass configClass, CombinedIndexBuildItem combinedIndex, BuildProducer generatedClasses, BuildProducer reflectiveClasses, @@ -94,7 +93,7 @@ public static void processExtensionConfigMapping( } private static void processConfigClass( - ConfigClassWithPrefix configClassWithPrefix, + ConfigClass configClassWithPrefix, Kind configClassKind, boolean isApplicationClass, CombinedIndexBuildItem combinedIndex, @@ -143,7 +142,6 @@ private static void processProperties( ConfigMappingInterface mapping = ConfigMappingLoader.getConfigMapping(configClass); for (Property property : mapping.getProperties()) { - Class returnType = property.getMethod().getReturnType(); String reason = ConfigMappingUtils.class.getSimpleName() + " Required to process property " + property.getPropertyName(); @@ -220,15 +218,6 @@ private static Kind getConfigClassType(AnnotationInstance instance) { } } - private static List> getHierarchy(Class mapping) { - List> interfaces = new ArrayList<>(); - for (Class i : mapping.getInterfaces()) { - interfaces.add(i); - interfaces.addAll(getHierarchy(i)); - } - return interfaces; - } - private static Set collectTypes(CombinedIndexBuildItem combinedIndex, Class configClass) { IndexView index = combinedIndex.getIndex(); DotName configIfaceName = DotName.createSimple(configClass.getName()); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java index 657e2a98d40e0..e82e137f8dd01 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java @@ -64,7 +64,7 @@ import io.quarkus.runtime.configuration.PropertiesUtil; import io.quarkus.runtime.configuration.QuarkusConfigFactory; import io.smallrye.config.ConfigMappings; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.Converters; import io.smallrye.config.KeyMap; import io.smallrye.config.SmallRyeConfig; @@ -1198,13 +1198,13 @@ private FieldDescriptor getOrCreateConverterInstance(Field field, ConverterType private void generateUnknownFilter() { Set names = new HashSet<>(); - for (ConfigClassWithPrefix buildTimeMapping : buildTimeConfigResult.getBuildTimeMappings()) { + for (ConfigClass buildTimeMapping : buildTimeConfigResult.getBuildTimeMappings()) { names.addAll(ConfigMappings.getProperties(buildTimeMapping).keySet()); } - for (ConfigClassWithPrefix staticConfigMapping : buildTimeConfigResult.getBuildTimeRunTimeMappings()) { + for (ConfigClass staticConfigMapping : buildTimeConfigResult.getBuildTimeRunTimeMappings()) { names.addAll(ConfigMappings.getProperties(staticConfigMapping).keySet()); } - for (ConfigClassWithPrefix runtimeConfigMapping : buildTimeConfigResult.getRunTimeMappings()) { + for (ConfigClass runtimeConfigMapping : buildTimeConfigResult.getRunTimeMappings()) { names.addAll(ConfigMappings.getProperties(runtimeConfigMapping).keySet()); } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigDescriptionBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigDescriptionBuildStep.java index 3e631cca49a24..4068bf65b1f16 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigDescriptionBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigDescriptionBuildStep.java @@ -35,7 +35,7 @@ import io.smallrye.config.ConfigMappingInterface.PrimitiveProperty; import io.smallrye.config.ConfigMappingInterface.Property; import io.smallrye.config.ConfigMappings; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; public class ConfigDescriptionBuildStep { @@ -120,9 +120,9 @@ public void accept(Container node) { } } - private void processMappings(List mappings, List descriptionBuildItems, + private void processMappings(List mappings, List descriptionBuildItems, Properties javaDocProperties, ConfigPhase configPhase) { - for (ConfigClassWithPrefix mapping : mappings) { + for (ConfigClass mapping : mappings) { Map properties = ConfigMappings.getProperties(mapping); for (Map.Entry entry : properties.entrySet()) { String propertyName = entry.getKey(); 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 134e3c0af1a10..2a9ce52ff6a43 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 @@ -88,7 +88,7 @@ import io.quarkus.runtime.configuration.RuntimeOverrideConfigSource; import io.quarkus.runtime.configuration.RuntimeOverrideConfigSourceBuilder; import io.quarkus.runtime.configuration.StaticInitConfigBuilder; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.ConfigSourceFactory; import io.smallrye.config.ConfigSourceInterceptor; import io.smallrye.config.ConfigSourceInterceptorFactory; @@ -184,14 +184,14 @@ void generateMappings( processConfigMapping(combinedIndex, generatedClasses, reflectiveClasses, reflectiveMethods, configClasses, additionalConstrainedClasses); - List buildTimeRunTimeMappings = configItem.getReadResult().getBuildTimeRunTimeMappings(); - for (ConfigClassWithPrefix buildTimeRunTimeMapping : buildTimeRunTimeMappings) { + List buildTimeRunTimeMappings = configItem.getReadResult().getBuildTimeRunTimeMappings(); + for (ConfigClass buildTimeRunTimeMapping : buildTimeRunTimeMappings) { processExtensionConfigMapping(buildTimeRunTimeMapping, combinedIndex, generatedClasses, reflectiveClasses, reflectiveMethods, configClasses, additionalConstrainedClasses); } - List runTimeMappings = configItem.getReadResult().getRunTimeMappings(); - for (ConfigClassWithPrefix runTimeMapping : runTimeMappings) { + List runTimeMappings = configItem.getReadResult().getRunTimeMappings(); + for (ConfigClass runTimeMapping : runTimeMappings) { processExtensionConfigMapping(runTimeMapping, combinedIndex, generatedClasses, reflectiveClasses, reflectiveMethods, configClasses, additionalConstrainedClasses); } @@ -239,7 +239,7 @@ void generateBuilders( Set configCustomizers = discoverService(SmallRyeConfigBuilderCustomizer.class, reflectiveClass); // For Static Init Config - Set staticMappings = new HashSet<>(); + Set staticMappings = new HashSet<>(); staticMappings.addAll(staticSafeConfigMappings(configMappings)); staticMappings.addAll(configItem.getReadResult().getBuildTimeRunTimeMappings()); Set staticCustomizers = new HashSet<>(staticSafeServices(configCustomizers)); @@ -261,7 +261,7 @@ void generateBuilders( reflectiveClass.produce(ReflectiveClassBuildItem.builder(CONFIG_STATIC_NAME).build()); // For RunTime Config - Set runTimeMappings = new HashSet<>(); + Set runTimeMappings = new HashSet<>(); runTimeMappings.addAll(runtimeConfigMappings(configMappings)); runTimeMappings.addAll(configItem.getReadResult().getBuildTimeRunTimeMappings()); runTimeMappings.addAll(configItem.getReadResult().getRunTimeMappings()); @@ -569,7 +569,7 @@ private static void generateConfigBuilder( Set configSourceFactories, Set secretKeyHandlers, Set secretKeyHandlerFactories, - Set mappings, + Set mappings, Set configCustomizers, Set configBuilders) { @@ -630,7 +630,7 @@ private static void generateConfigBuilder( method.newInstance(MethodDescriptor.ofConstructor(secretKeyHandlerFactory))); } - for (ConfigClassWithPrefix mapping : mappings) { + for (ConfigClass mapping : mappings) { method.invokeStaticMethod(WITH_MAPPING, configBuilder, method.load(mapping.getKlass().getName()), method.load(mapping.getPrefix())); } @@ -704,16 +704,16 @@ private static Set staticSafeServices(Set services) { return staticSafe; } - private static Set staticSafeConfigMappings(List configMappings) { + private static Set staticSafeConfigMappings(List configMappings) { return configMappings.stream() .filter(ConfigMappingBuildItem::isStaticInitSafe) - .map(ConfigMappingBuildItem::toConfigClassWithPrefix) + .map(ConfigMappingBuildItem::toConfigClass) .collect(toSet()); } - private static Set runtimeConfigMappings(List configMappings) { + private static Set runtimeConfigMappings(List configMappings) { return configMappings.stream() - .map(ConfigMappingBuildItem::toConfigClassWithPrefix) + .map(ConfigMappingBuildItem::toConfigClass) .collect(toSet()); } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/Substitutions.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/Substitutions.java index a038fca62a580..5b143025bee3d 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/Substitutions.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/Substitutions.java @@ -9,6 +9,8 @@ import com.oracle.svm.core.annotate.TargetElement; import io.smallrye.common.constraint.Assert; +import io.smallrye.config.ConfigMappingInterface; +import io.smallrye.config.ConfigMappingLoader; import io.smallrye.config.ConfigMappingMetadata; /** @@ -22,7 +24,7 @@ static final class Target_ConfigurationProviderResolver { private static volatile ConfigProviderResolver instance; } - @TargetClass(className = "io.smallrye.config.ConfigMappingLoader") + @TargetClass(ConfigMappingLoader.class) static final class Target_ConfigMappingLoader { @Substitute static Class loadClass(final Class parent, final ConfigMappingMetadata configMappingMetadata) { @@ -39,7 +41,7 @@ private static Class defineClass(final Class parent, final String classNam } } - @TargetClass(className = "io.smallrye.config.ConfigMappingInterface") + @TargetClass(ConfigMappingInterface.class) static final class Target_ConfigMappingInterface { @Alias static ClassValue cv = null; @@ -62,7 +64,7 @@ public byte[] getClassBytes() { } } - @TargetClass(className = "io.smallrye.config.ConfigMappingClass") + @TargetClass(value = ConfigMappingLoader.class, innerClass = "ConfigMappingClass") static final class Target_ConfigMappingClass { @Alias static ClassValue cv = null; diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java index 7f0975e5aaafe..4f322f5097813 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java @@ -7,7 +7,7 @@ import static io.quarkus.deployment.builditem.ConfigClassBuildItem.Kind.PROPERTIES; import static io.quarkus.deployment.configuration.ConfigMappingUtils.CONFIG_MAPPING_NAME; import static io.quarkus.deployment.configuration.ConfigMappingUtils.processConfigClasses; -import static io.smallrye.config.ConfigMappings.ConfigClassWithPrefix.configClassWithPrefix; +import static io.smallrye.config.ConfigMappings.ConfigClass.configClass; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static org.eclipse.microprofile.config.inject.ConfigProperties.UNCONFIGURED_PREFIX; @@ -75,7 +75,7 @@ import io.quarkus.gizmo.ResultHandle; import io.quarkus.hibernate.validator.spi.AdditionalConstrainedClassBuildItem; import io.quarkus.runtime.annotations.ConfigPhase; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.inject.ConfigProducer; /** @@ -497,13 +497,13 @@ void registerConfigClasses( // TODO - Register ConfigProperties during build time context.registerNonDefaultConstructor( - ConfigClassWithPrefix.class.getDeclaredConstructor(Class.class, String.class), - configClassWithPrefix -> Stream.of(configClassWithPrefix.getKlass(), configClassWithPrefix.getPrefix()) + ConfigClass.class.getDeclaredConstructor(Class.class, String.class), + configClass -> Stream.of(configClass.getKlass(), configClass.getPrefix()) .collect(toList())); recorder.registerConfigProperties( configProperties.stream() - .map(p -> configClassWithPrefix(p.getConfigClass(), p.getPrefix())) + .map(p -> configClass(p.getConfigClass(), p.getPrefix())) .collect(toSet())); } diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/IndexedPropertiesInjectionTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/IndexedPropertiesInjectionTest.java index 3f80ccc8d7a2d..43b58186c0135 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/IndexedPropertiesInjectionTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/IndexedPropertiesInjectionTest.java @@ -59,7 +59,7 @@ void indexed() { assertEquals(Stream.of(new ConvertedValue("out")).collect(Collectors.toList()), indexedBean.getConverted()); assertEquals(Stream.of("a", "b", "c").collect(Collectors.toList()), indexedBean.getDefaults()); assertEquals(Stream.of("e", "f").collect(Collectors.toList()), indexedBean.getOverrideDefaults()); - assertEquals(Stream.of("a", "b", "c").collect(Collectors.toList()), indexedBean.getComma()); + assertEquals(Stream.of("a", "b").collect(Collectors.toList()), indexedBean.getComma()); } @Test diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigRecorder.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigRecorder.java index befdd6537eeee..9883e48d02336 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigRecorder.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigRecorder.java @@ -18,7 +18,7 @@ import io.quarkus.runtime.annotations.Recorder; import io.quarkus.runtime.configuration.ConfigurationException; import io.smallrye.config.ConfigMappings; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.ConfigValidationException; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.inject.ConfigProducerUtil; @@ -75,7 +75,7 @@ public void validateConfigProperties(Set properties) { } } - public void registerConfigProperties(final Set configClasses) { + public void registerConfigProperties(final Set configClasses) { try { SmallRyeConfig config = (SmallRyeConfig) ConfigProvider.getConfig(); ConfigMappings.registerConfigProperties(config, configClasses); diff --git a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java index d45e7bb5d90b7..bf598bd71f352 100644 --- a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java +++ b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java @@ -1,6 +1,7 @@ package io.quarkus.test.component; import static io.quarkus.commons.classloading.ClassLoaderHelper.fromClassNameToResourceName; +import static io.smallrye.config.ConfigMappings.ConfigClass.configClass; import java.io.File; import java.io.FileOutputStream; @@ -120,7 +121,7 @@ import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.test.InjectMock; import io.smallrye.config.ConfigMapping; -import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; +import io.smallrye.config.ConfigMappings.ConfigClass; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.SmallRyeConfigProviderResolver; @@ -440,11 +441,11 @@ private void startContainer(ExtensionContext context, Lifecycle testInstanceLife new QuarkusComponentTestConfigSource(configuration.configProperties, configuration.configSourceOrdinal)); @SuppressWarnings("unchecked") - Set configMappings = store(context).get(KEY_CONFIG_MAPPINGS, Set.class); + Set configMappings = store(context).get(KEY_CONFIG_MAPPINGS, Set.class); if (configMappings != null) { // Register the mappings found during bean discovery - for (ConfigClassWithPrefix mapping : configMappings) { - configBuilder.withMapping(mapping.getKlass(), mapping.getPrefix()); + for (ConfigClass mapping : configMappings) { + configBuilder.withMapping(mapping); } } if (configuration.configBuilderCustomizer != null) { @@ -789,7 +790,7 @@ public void register(RegistrationContext registrationContext) { } if (!prefixToConfigMappings.isEmpty()) { - Set configMappings = new HashSet<>(); + Set configMappings = new HashSet<>(); for (Entry> e : prefixToConfigMappings.entrySet()) { for (String mapping : e.getValue()) { DotName mappingName = DotName.createSimple(mapping); @@ -799,8 +800,7 @@ public void register(RegistrationContext registrationContext) { .param("mappingClass", mapping) .param("prefix", e.getKey()) .done(); - configMappings.add(ConfigClassWithPrefix - .configClassWithPrefix(ConfigMappingBeanCreator.tryLoad(mapping), e.getKey())); + configMappings.add(configClass(ConfigMappingBeanCreator.tryLoad(mapping), e.getKey())); } } store(extensionContext).put(KEY_CONFIG_MAPPINGS, configMappings);