diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/AbstractConfigListener.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/AbstractConfigListener.java index 4eb92d7e84277..6e99c7e9b3be1 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/AbstractConfigListener.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/AbstractConfigListener.java @@ -14,6 +14,8 @@ import io.quarkus.annotation.processor.documentation.config.discovery.EnumDefinition; import io.quarkus.annotation.processor.documentation.config.discovery.EnumDefinition.EnumConstant; import io.quarkus.annotation.processor.documentation.config.discovery.ResolvedType; +import io.quarkus.annotation.processor.documentation.config.model.ConfigPhase; +import io.quarkus.annotation.processor.documentation.config.model.ExtensionModule; import io.quarkus.annotation.processor.documentation.config.util.Types; import io.quarkus.annotation.processor.util.Config; import io.quarkus.annotation.processor.util.Utils; @@ -66,6 +68,18 @@ public void onResolvedEnum(TypeElement enumTypeElement) { configCollector.addResolvedEnum(enumDefinition); } + protected void validateRuntimeConfigOnDeploymentModules(ConfigPhase configPhase, TypeElement configRoot) { + if (configPhase.equals(ConfigPhase.RUN_TIME) || configPhase.equals(ConfigPhase.BUILD_AND_RUN_TIME_FIXED)) { + ExtensionModule.ExtensionModuleType type = config.getExtensionModule().type(); + if (type.equals(ExtensionModule.ExtensionModuleType.DEPLOYMENT)) { + throw new IllegalStateException(String.format( + "Error on %s: Configuration classes with ConfigPhase.RUN_TIME or " + + "ConfigPhase.BUILD_AND_RUNTIME_FIXED phases, must reside in the respective module.", + configRoot.getSimpleName().toString())); + } + } + } + protected void handleCommonPropertyAnnotations(DiscoveryConfigProperty.Builder builder, Map propertyAnnotations, ResolvedType resolvedType, String sourceElementName) { diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigMappingListener.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigMappingListener.java index cda99142c602e..ea4135f7adfe3 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigMappingListener.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigMappingListener.java @@ -75,6 +75,8 @@ public Optional onConfigRoot(TypeElement configRoot) { } } + validateRuntimeConfigOnDeploymentModules(configPhase, configRoot); + for (Map.Entry entry : configMappingAnnotion.getElementValues() .entrySet()) { if ("prefix()".equals(entry.getKey().toString())) { diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/LegacyConfigRootListener.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/LegacyConfigRootListener.java index 2410b8c62b9d6..f675f902fc9fe 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/LegacyConfigRootListener.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/LegacyConfigRootListener.java @@ -79,6 +79,8 @@ public Optional onConfigRoot(TypeElement configRoot) { } } + validateRuntimeConfigOnDeploymentModules(configPhase, configRoot); + String overriddenDocPrefix = null; if (configDocPrefixAnnotation != null) { for (Map.Entry entry : configDocPrefixAnnotation