Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable MP ConfigProperties and ConfigMapping #20275

Closed
essobedo opened this issue Sep 20, 2021 · 5 comments · Fixed by #19965
Closed

Allow to disable MP ConfigProperties and ConfigMapping #20275

essobedo opened this issue Sep 20, 2021 · 5 comments · Fixed by #19965
Labels
area/config kind/enhancement New feature or request
Milestone

Comments

@essobedo
Copy link
Contributor

Description

Up to now, if we want to ease the mapping of the configuration, we can rely on the annotations @ConfigProperties from MicroProfile Config and/or @ConfigMapping from SmallRye Config. If used, Quarkus will check at runtime that the corresponding properties are available in the configuration which can be a problem if this part of the configuration only makes sense for production but not for the tests.

Implementation ideas

The idea could be to rely on build time conditions to enable or not the annotations @ConfigProperties and/or @ConfigMapping.

@radcortez
Copy link
Member

I'm not totally sure if we should add this. Can you please elaborate more on a concrete use case? Thanks!

@essobedo
Copy link
Contributor Author

In my use case I have several profiles that we will call a and b, the code of both profiles is shared as they have a lot in common, so they also share some configuration classes. We rely on build time conditions to indicate Quarkus which Beans/JAX-RS Components/Configuration classes/properties... to enable or not according to the profile used at build time. Consequently, we have some specific configuration classes that map properties only available when the profile a is used so when we start the application with the profile b, it complains because the properties cannot be found. So the idea of this task is to be able to use build time conditions to disable or not a Configuration class or interface, like it is already possible with the deprecated annotation io.quarkus.arc.config.ConfigProperties.

@IfBuildProfile("a")
@ConfigProperties(prefix = "a")
public class SpecificToA {
    String somePropertySpecificToA;
 }

Is-it clear now?

@radcortez
Copy link
Member

If I remember correctly, @IfBuildProfile does not include the bean during runtime, so it is effectively removed. If that is the case, then we can pick my other PR here #19965 and apply the same logic. If a bean that you use is unused and injects a mapping / properties, that one is also removed. In this way, you don't need additional annotations and it is done automatically.

@essobedo
Copy link
Contributor Author

@radcortez If it allows to do the same thing that the test I have in my PR, it would be great

@radcortez
Copy link
Member

Reopening, to close only when linked PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/enhancement New feature or request
Projects
None yet
3 participants