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 5229798998106..10b0a98d60675 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 @@ -299,8 +299,17 @@ void registerConfigMappingsBean( return; } - Map configMappingTypes = configClassesToTypesMap(configClasses, MAPPING); Set configMappings = new HashSet<>(); + + // Add beans for all unremovable mappings + for (ConfigClassBuildItem configClass : configClasses) { + if (configClass.getConfigClass().isAnnotationPresent(Unremovable.class)) { + configMappings.add(configClass); + } + } + + // Add beans for all injection points + Map configMappingTypes = configClassesToTypesMap(configClasses, MAPPING); for (InjectionPointInfo injectionPoint : beanRegistration.getInjectionPoints()) { Type type = Type.create(injectionPoint.getRequiredType().name(), Type.Kind.CLASS); ConfigClassBuildItem configClass = configMappingTypes.get(type); @@ -309,6 +318,7 @@ void registerConfigMappingsBean( } } + // Generate the mappings beans for (ConfigClassBuildItem configClass : configMappings) { BeanConfigurator bean = beanRegistration.getContext() .configure(configClass.getConfigClass()) diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/UnremovedConfigMappingTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/UnremovedConfigMappingTest.java index a7278367d2a54..ff4f50fb535d6 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/UnremovedConfigMappingTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/UnremovedConfigMappingTest.java @@ -3,8 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import jakarta.enterprise.inject.spi.CDI; import jakarta.inject.Inject; +import org.eclipse.microprofile.config.inject.ConfigProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -29,6 +31,12 @@ public class UnremovedConfigMappingTest { void unremoved() { UnremovedConfigMapping mapping = config.getConfigMapping(UnremovedConfigMapping.class); assertEquals("1234", mapping.prop()); + + mapping = CDI.current().select(UnremovedConfigMapping.class).get(); + assertEquals("1234", mapping.prop()); + + UnremovedConfigProperties properties = CDI.current().select(UnremovedConfigProperties.class).get(); + assertEquals("1234", properties.prop); } @Test @@ -54,4 +62,10 @@ public interface ExtendsBase extends Base { @WithDefault("default") String myProp(); } + + @Unremovable + @ConfigProperties(prefix = "mapping") + public static class UnremovedConfigProperties { + String prop; + } }