use of io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem in project quarkus by quarkusio.
the class ConfigEditorProcessor method handleRequests.
@BuildStep
void handleRequests(BuildProducer<DevConsoleRouteBuildItem> devConsoleRouteProducer, Optional<DevServicesLauncherConfigResultBuildItem> devServicesLauncherConfig) {
CurrentConfig.EDITOR = ConfigEditorProcessor::updateConfig;
devConsoleRouteProducer.produce(new DevConsoleRouteBuildItem("config/all", "GET", (e) -> {
e.end(Buffer.buffer(getConfig()));
}));
}
use of io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem in project quarkus by quarkusio.
the class SwaggerUiProcessor method getSwaggerUiFinalDestination.
@BuildStep
public void getSwaggerUiFinalDestination(NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem, LaunchModeBuildItem launchMode, SwaggerUiConfig swaggerUiConfig, SmallRyeOpenApiConfig openapi, Optional<DevServicesLauncherConfigResultBuildItem> devServicesLauncherConfig, BuildProducer<WebJarBuildItem> webJarBuildProducer) throws Exception {
if (shouldInclude(launchMode, swaggerUiConfig)) {
if ("/".equals(swaggerUiConfig.path)) {
throw new ConfigurationException("quarkus.swagger-ui.path was set to \"/\", this is not allowed as it blocks the application from serving anything else.", Set.of("quarkus.swagger-ui.path"));
}
if (openapi.path.equalsIgnoreCase(swaggerUiConfig.path)) {
throw new ConfigurationException("quarkus.smallrye-openapi.path and quarkus.swagger-ui.path was set to the same value, this is not allowed as the paths needs to be unique [" + openapi.path + "].", Set.of("quarkus.smallrye-openapi.path", "quarkus.swagger-ui.path"));
}
if (devServicesLauncherConfig.isPresent()) {
DevServicesLauncherConfigResultBuildItem devServicesLauncherConfigResult = devServicesLauncherConfig.get();
Map<String, String> devServiceConfig = devServicesLauncherConfigResult.getConfig();
if (devServiceConfig != null && !devServiceConfig.isEmpty()) {
// Map client Id from OIDC Dev Services
if (devServiceConfig.containsKey(OIDC_CLIENT_ID) && !swaggerUiConfig.oauthClientId.isPresent()) {
String clientId = devServiceConfig.get(OIDC_CLIENT_ID);
swaggerUiConfig.oauthClientId = Optional.of(clientId);
}
}
}
String openApiPath = nonApplicationRootPathBuildItem.resolvePath(openapi.path);
String swaggerUiPath = nonApplicationRootPathBuildItem.resolvePath(swaggerUiConfig.path);
ThemeHref theme = swaggerUiConfig.theme.orElse(ThemeHref.feeling_blue);
NonApplicationRootPathBuildItem indexRootPathBuildItem = null;
if (launchMode.getLaunchMode().isDevOrTest()) {
indexRootPathBuildItem = nonApplicationRootPathBuildItem;
// In dev mode, default to persist Authorization true
if (!swaggerUiConfig.persistAuthorization.isPresent()) {
swaggerUiConfig.persistAuthorization = Optional.of(true);
}
}
byte[] indexHtmlContent = generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig, indexRootPathBuildItem);
webJarBuildProducer.produce(//
WebJarBuildItem.builder().artifactKey(SWAGGER_UI_WEBJAR_ARTIFACT_KEY).root(//
SWAGGER_UI_WEBJAR_STATIC_RESOURCES_PATH).filter(new WebJarResourcesFilter() {
@Override
public FilterResult apply(String fileName, InputStream file) throws IOException {
if (!fileName.equals(theme.toString()) && fileName.startsWith("theme-")) {
return new FilterResult(null, true);
}
if (fileName.endsWith("index.html")) {
return new FilterResult(new ByteArrayInputStream(indexHtmlContent), true);
}
return new FilterResult(file, false);
}
}).build());
}
}
use of io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem in project quarkus by quarkusio.
the class DevServicesConfigBuildStep method setup.
@BuildStep
@Produce(ServiceStartBuildItem.class)
DevServicesLauncherConfigResultBuildItem setup(BuildProducer<RunTimeConfigurationDefaultBuildItem> runtimeConfig, List<DevServicesConfigResultBuildItem> devServicesConfigResultBuildItems, List<DevServicesResultBuildItem> devServicesResultBuildItems, CuratedApplicationShutdownBuildItem shutdownBuildItem) {
Map<String, String> newProperties = new HashMap<>(devServicesConfigResultBuildItems.stream().collect(Collectors.toMap(DevServicesConfigResultBuildItem::getKey, DevServicesConfigResultBuildItem::getValue)));
for (DevServicesResultBuildItem resultBuildItem : devServicesResultBuildItems) {
newProperties.putAll(resultBuildItem.getConfig());
}
Config config = ConfigProvider.getConfig();
// we also check the current config, as the dev service may have been disabled by explicit config
if (oldConfig != null) {
for (Map.Entry<String, String> entry : oldConfig.entrySet()) {
if (!newProperties.containsKey(entry.getKey()) && config.getOptionalValue(entry.getKey(), String.class).isEmpty()) {
newProperties.put(entry.getKey(), entry.getValue());
}
}
} else {
shutdownBuildItem.addCloseTask(new Runnable() {
@Override
public void run() {
oldConfig = null;
}
}, true);
}
for (Map.Entry<String, String> entry : newProperties.entrySet()) {
runtimeConfig.produce(new RunTimeConfigurationDefaultBuildItem(entry.getKey(), entry.getValue()));
}
oldConfig = newProperties;
return new DevServicesLauncherConfigResultBuildItem(Collections.unmodifiableMap(newProperties));
}
use of io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem in project quarkus by quarkusio.
the class NativeDevServicesHandler method accept.
@Override
public void accept(Object o, BuildResult buildResult) {
BiConsumer<String, String> propertyConsumer = (BiConsumer<String, String>) o;
DevServicesLauncherConfigResultBuildItem devServicesProperties = buildResult.consume(DevServicesLauncherConfigResultBuildItem.class);
for (var entry : devServicesProperties.getConfig().entrySet()) {
propertyConsumer.accept(entry.getKey(), entry.getValue());
}
}
Aggregations