From 33d2de7b2737ea0d4e72b19a73af58deaab4fb62 Mon Sep 17 00:00:00 2001 From: Christian Berger Date: Wed, 29 Mar 2023 23:07:49 +0200 Subject: [PATCH] fix: Alignment of the capability detection logic --- .../codegen/OpenApiGeneratorCodeGenBase.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java index 20335555..7508a110 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java @@ -33,7 +33,6 @@ import io.quarkus.deployment.Capability; import io.quarkus.deployment.CodeGenContext; import io.quarkus.deployment.CodeGenProvider; -import io.quarkus.maven.dependency.ResolvedDependency; import io.smallrye.config.SmallRyeConfig; /** @@ -119,20 +118,18 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { return false; } - private boolean isJacksonReactiveClientPresent(CodeGenContext context) { - return context.applicationModel().getDependencies().stream() - .anyMatch(this::isJacksonReactiveClient); + private static boolean isJacksonReactiveClientPresent(CodeGenContext context) { + return isExtensionCapabilityPresent(context, Capability.REST_CLIENT_REACTIVE_JACKSON); } - private boolean isJacksonClassicClientPresent(CodeGenContext context) { - return context.applicationModel().getExtensionCapabilities().stream() - .flatMap(extensionCapability -> extensionCapability.getProvidesCapabilities().stream()) - .anyMatch(Capability.RESTEASY_JSON_JACKSON_CLIENT::equals); + private static boolean isJacksonClassicClientPresent(CodeGenContext context) { + return isExtensionCapabilityPresent(context, Capability.RESTEASY_JSON_JACKSON_CLIENT); } - private boolean isJacksonReactiveClient(ResolvedDependency resolvedDependency) { - return "quarkus-rest-client-reactive-jackson".equals(resolvedDependency.getArtifactId()) - && "io.quarkus".equals(resolvedDependency.getGroupId()); + private static boolean isExtensionCapabilityPresent(CodeGenContext context, String capability) { + return context.applicationModel().getExtensionCapabilities().stream() + .flatMap(extensionCapability -> extensionCapability.getProvidesCapabilities().stream()) + .anyMatch(capability::equals); } // TODO: do not generate if the output dir has generated files and the openapi file has the same checksum of the previous run