From 2113ab1a48cef0e10bc428827e53e3be5ab79dba Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 9 Feb 2021 14:28:02 +0200 Subject: [PATCH] Fix the native httpRoot & nonAppRoot issue. Made the code more consistent between the 3 UIs Signed-off-by:Phillip Kruger --- .../deployment/SmallRyeGraphQLProcessor.java | 19 ++++++++++--------- .../deployment/SmallRyeHealthProcessor.java | 8 ++++---- .../deployment/SwaggerUiProcessor.java | 6 ++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index e60376b90d740..4fa39309e35a9 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -470,8 +470,8 @@ void getGraphqlUiFinalDestination( } String graphQLPath = httpRootPath.adjustPath(graphQLConfig.rootPath); - String graphQLUiPath = nonApplicationRootPathBuildItem - .adjustPath(graphQLConfig.ui.rootPath); + String graphQLUiPath = httpRootPath + .adjustPath(nonApplicationRootPathBuildItem.adjustPath(graphQLConfig.ui.rootPath)); AppArtifact artifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, GRAPHQL_UI_WEBJAR_GROUP_ID, GRAPHQL_UI_WEBJAR_ARTIFACT_ID); @@ -479,13 +479,15 @@ void getGraphqlUiFinalDestination( Path tempPath = WebJarUtil.copyResourcesForDevOrTest(curateOutcomeBuildItem, launchMode, artifact, GRAPHQL_UI_WEBJAR_PREFIX); WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLPath, LINE_TO_UPDATE, LINE_FORMAT); - WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), httpRootPath.adjustPath(graphQLUiPath), + WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLUiPath, UI_LINE_TO_UPDATE, UI_LINE_FORMAT); - smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(tempPath.toAbsolutePath().toString(), - httpRootPath.adjustPath(graphQLUiPath))); + smallRyeGraphQLBuildProducer + .produce(new SmallRyeGraphQLBuildItem(tempPath.toAbsolutePath().toString(), graphQLUiPath)); notFoundPageDisplayableEndpointProducer - .produce(new NotFoundPageDisplayableEndpointBuildItem(graphQLUiPath + "/", "MicroProfile GraphQL UI")); + .produce(new NotFoundPageDisplayableEndpointBuildItem( + nonApplicationRootPathBuildItem.adjustPath(graphQLConfig.ui.rootPath) + "/", + "MicroProfile GraphQL UI")); // Handle live reload of branding files if (liveReloadBuildItem.isLiveReload() && !liveReloadBuildItem.getChangedResources().isEmpty()) { @@ -506,7 +508,7 @@ void getGraphqlUiFinalDestination( LINE_FORMAT) .getBytes(StandardCharsets.UTF_8); content = WebJarUtil - .updateUrl(new String(content, StandardCharsets.UTF_8), httpRootPath.adjustPath(graphQLUiPath), + .updateUrl(new String(content, StandardCharsets.UTF_8), graphQLUiPath, UI_LINE_TO_UPDATE, UI_LINE_FORMAT) .getBytes(StandardCharsets.UTF_8); @@ -517,8 +519,7 @@ void getGraphqlUiFinalDestination( nativeImageResourceProducer.produce(new NativeImageResourceBuildItem(fileName)); } - smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(GRAPHQL_UI_FINAL_DESTINATION, - httpRootPath.adjustPath(graphQLUiPath))); + smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(GRAPHQL_UI_FINAL_DESTINATION, graphQLUiPath)); } } } diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index 3f8d8135b5909..99e57df6b6ed1 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -417,6 +417,7 @@ void registerUiExtension( } String healthPath = httpRootPath.adjustPath(nonApplicationRootPathBuildItem.adjustPath(healthConfig.rootPath)); + String healthUiPath = httpRootPath.adjustPath(nonApplicationRootPathBuildItem.adjustPath(healthConfig.ui.rootPath)); AppArtifact artifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, HEALTH_UI_WEBJAR_GROUP_ID, HEALTH_UI_WEBJAR_ARTIFACT_ID); @@ -426,8 +427,8 @@ void registerUiExtension( HEALTH_UI_WEBJAR_PREFIX); updateApiUrl(tempPath.resolve(FILE_TO_UPDATE), healthPath); - smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(tempPath.toAbsolutePath().toString(), - httpRootPath.adjustPath(healthConfig.ui.rootPath))); + smallRyeHealthBuildProducer + .produce(new SmallRyeHealthBuildItem(tempPath.toAbsolutePath().toString(), healthUiPath)); notFoundPageDisplayableEndpointProducer .produce(new NotFoundPageDisplayableEndpointBuildItem( @@ -457,8 +458,7 @@ void registerUiExtension( nativeImageResourceProducer.produce(new NativeImageResourceBuildItem(fileName)); } - smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(HEALTH_UI_FINAL_DESTINATION, - httpRootPath.adjustPath(healthConfig.ui.rootPath))); + smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(HEALTH_UI_FINAL_DESTINATION, healthUiPath)); } } } diff --git a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java index 4fe7fb361d1b3..c59d4a84276cd 100644 --- a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java +++ b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java @@ -107,8 +107,7 @@ public void getSwaggerUiFinalDestination( WebJarUtil.updateFile(tempPath.resolve("index.html"), generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig)); - swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(tempPath.toAbsolutePath().toString(), - nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path))); + swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(tempPath.toAbsolutePath().toString(), swaggerUiPath)); displayableEndpoints.produce(new NotFoundPageDisplayableEndpointBuildItem( nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path + "/"), "Open API UI")); @@ -136,8 +135,7 @@ public void getSwaggerUiFinalDestination( nativeImageResourceBuildItemBuildProducer.produce(new NativeImageResourceBuildItem(fileName)); } } - swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(SWAGGER_UI_FINAL_DESTINATION, - nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path))); + swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(SWAGGER_UI_FINAL_DESTINATION, swaggerUiPath)); } } }