use of io.quarkus.deployment.builditem.GeneratedResourceBuildItem in project keycloak by keycloak.
the class KeycloakProcessor method persistBuildTimeProperties.
/**
* <p>Make the build time configuration available at runtime so that the server can run without having to specify some of
* the properties again.
*/
@BuildStep(onlyIf = IsReAugmentation.class)
void persistBuildTimeProperties(BuildProducer<GeneratedResourceBuildItem> resources) {
Properties properties = new Properties();
for (String name : getPropertyNames()) {
PropertyMapper mapper = PropertyMappers.getMapper(name);
ConfigValue value = null;
if (mapper == null) {
if (name.startsWith(NS_QUARKUS)) {
value = Configuration.getConfigValue(name);
if (!QuarkusPropertiesConfigSource.isSameSource(value)) {
continue;
}
}
} else if (mapper.isBuildTime()) {
name = mapper.getFrom();
value = Configuration.getConfigValue(name);
}
if (value != null && value.getValue() != null) {
properties.put(name, value.getValue());
}
}
for (File jar : getProviderFiles().values()) {
properties.put(String.format("kc.provider.file.%s.last-modified", jar.getName()), String.valueOf(jar.lastModified()));
}
String profile = Environment.getProfile();
if (profile != null) {
properties.put(Environment.PROFILE, profile);
properties.put(ProfileManager.QUARKUS_PROFILE_PROP, profile);
}
properties.put(QUARKUS_PROPERTY_ENABLED, String.valueOf(QuarkusPropertiesConfigSource.getConfigurationFile() != null));
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
properties.store(outputStream, " Auto-generated, DO NOT change this file");
resources.produce(new GeneratedResourceBuildItem(PersistedConfigSource.PERSISTED_PROPERTIES, outputStream.toByteArray()));
} catch (Exception cause) {
throw new RuntimeException("Failed to persist configuration", cause);
}
}
Aggregations