Skip to content

Extension config for both build and run time with same prefix #32674

Closed

Description

Describe the bug

Extension writing guide recommends using @ConfigMapping instead of @ConfigRoot with prefix and name but in case of split config with same prefix for build time and run time SR Config validation effectively forbids it.

Similar approach with @ConfigRoot(prefix = "my", name = "", phase = ...) seems to work fine.

See also: zulip thread.

Expected behavior

Ability to map configuration properties to both run time and build time config with validation failure only if the property is absent in both.

Actual behavior

ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: io.smallrye.config.ConfigValidationException: Configuration validation failed:
        my.greeting does not map to any root

How to Reproduce?

Reproducer:

  1. quarkus create extension org.acme:my-ext && cd my-ext
  2. Add following classes to runtime module
@ConfigMapping(prefix = "my")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface MyExtRunTimeConfig {
  /** */
  String greeting();
}

@ConfigMapping(prefix = "my")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface MyExtBuildTimeConfig {
  /** */
  @WithDefault("true")
  boolean enabled();
}
  1. Add <module>intergration-tests</module> to root pom.xml
  2. Add my.greeting = Hi to integration-tests/src/main/resources/application.properties
  3. Run quarkus dev

Output of uname -a or ver

Linux unterwelt 6.2.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 07 Apr 2023 02:10:43 +0000 x86_64 GNU/Linux

Output of java -version

openjdk 17.0.6 2023-01-17 OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10) OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.6.Final

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

Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions