From b2fc6fadeb16abec31ef4bb258aab78d5cfaed1d Mon Sep 17 00:00:00 2001 From: Alan Boshier Date: Tue, 24 Sep 2024 16:07:39 +0100 Subject: [PATCH] 678: register Severity enum for reflection so native app builds don't need to do this themselves --- .../logging/deployment/LoggingBuildSteps.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/logging/deployment/src/main/java/io/quarkiverse/googlecloudservices/logging/deployment/LoggingBuildSteps.java b/logging/deployment/src/main/java/io/quarkiverse/googlecloudservices/logging/deployment/LoggingBuildSteps.java index 5d5cba34..29b27140 100644 --- a/logging/deployment/src/main/java/io/quarkiverse/googlecloudservices/logging/deployment/LoggingBuildSteps.java +++ b/logging/deployment/src/main/java/io/quarkiverse/googlecloudservices/logging/deployment/LoggingBuildSteps.java @@ -1,5 +1,8 @@ package io.quarkiverse.googlecloudservices.logging.deployment; +import java.util.ArrayList; +import java.util.List; + import io.quarkiverse.googlecloudservices.logging.runtime.LoggingConfiguration; import io.quarkiverse.googlecloudservices.logging.runtime.TraceInfoExtractor; import io.quarkiverse.googlecloudservices.logging.runtime.cdi.LoggingProducer; @@ -11,6 +14,7 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.LogHandlerBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; public class LoggingBuildSteps { @@ -38,4 +42,14 @@ public UnremovableBeanBuildItem helperClasses() { public LogHandlerBuildItem handler(LoggingConfiguration config, LoggingHandlerFactory factory) { return new LogHandlerBuildItem(factory.create(config)); } + + @BuildStep + public List registerReflectiveClasses() { + List items = new ArrayList<>(); + // Required for native builds as LoggingHandler uses Gson to serialize severity values + items.add(ReflectiveClassBuildItem.builder("com.google.cloud.logging.Severity") + .fields(true) + .build()); + return items; + } }