Search in sources :

Example 1 with StaticInitConfigSourceProviderBuildItem

use of io.quarkus.deployment.builditem.StaticInitConfigSourceProviderBuildItem in project keycloak by keycloak.

the class KeycloakProcessor method prepareTestEnvironment.

@BuildStep(onlyIf = IsIntegrationTest.class)
void prepareTestEnvironment(BuildProducer<StaticInitConfigSourceProviderBuildItem> configSources, DevServicesDatasourceResultBuildItem dbConfig) {
    configSources.produce(new StaticInitConfigSourceProviderBuildItem("org.keycloak.quarkus.runtime.configuration.test.TestKeycloakConfigSourceProvider"));
    // this might be too sensitive and break if Quarkus changes the behavior
    if (dbConfig != null && dbConfig.getDefaultDatasource() != null) {
        Map<String, String> configProperties = dbConfig.getDefaultDatasource().getConfigProperties();
        for (Entry<String, String> dbConfigProperty : configProperties.entrySet()) {
            PropertyMapper mapper = PropertyMappers.getMapper(dbConfigProperty.getKey());
            if (mapper == null) {
                continue;
            }
            String kcProperty = mapper.getFrom();
            if (kcProperty.endsWith("db")) {
                // db kind set when running tests
                continue;
            }
            System.setProperty(kcProperty, dbConfigProperty.getValue());
        }
    }
}
Also used : StaticInitConfigSourceProviderBuildItem(io.quarkus.deployment.builditem.StaticInitConfigSourceProviderBuildItem) PropertyMapper(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

BuildStep (io.quarkus.deployment.annotations.BuildStep)1 StaticInitConfigSourceProviderBuildItem (io.quarkus.deployment.builditem.StaticInitConfigSourceProviderBuildItem)1 PropertyMapper (org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper)1